特定のリンクが代わりに JQuery ロードを使用するスクリプトを作成しようとしています
これは動作しません。
function inload() {
$('#sausage').load(this.attr('href') + ' #sausage');
return false;
}
問題は私の t にあると思いますが、his.attr('href')
アドバイスが必要です。
何か案は?
素晴らしい
$("a").live("click",function(e){ //.live not .click so the function will also work on the newly loaded content
e.preventDefault(); //prevent the default action of clicking the link
var href = $(this).attr("href"); //grab the links href
$("body").load(href,callback); //load the contents of the href info the body of the page
});
//added a callback for running after the content has loaded if required
function callback(){
alert("content loaded");
}
に到達するには、実際にタグを使用していると仮定して、これhref
を簡単に行うことができます。this.href
<a/>
this
Dom Element
function inload() {
$('#sausage').load(this.href + ' #sausage');
return false;
}
それ以外の場合は使用$(this).attr('href');
する必要があります
$('#sausage').load($(this).attr('href')+'#sausage');
また
$('#sausage').load(this.href+'#sausage');