Jquery 属性的索引值
我正在使用以下代码 ...Jquery 属性的索引值,jquery,fancybox,Jquery,Fancybox,我正在使用以下代码 ... $('a').click(function( e ) { alert(this.id); // e.preventDefault(); // Uncomment this line if you don't want }); // to follow the link's href. $i=0;$i的 我想知道用户点击a href时它的id。比如read[1]read[2]等等 $('a').clic
$('a').click(function( e ) {
alert(this.id);
// e.preventDefault(); // Uncomment this line if you don't want
}); // to follow the link's href.
$i=0;$i的
我想知道用户点击a href时它的id。比如read[1]read[2]等等
$('a').click(function( e ) {
alert(this.id);
// e.preventDefault(); // Uncomment this line if you don't want
}); // to follow the link's href.
这将为所有行分配一个单击
事件,以防止链接的默认行为(在其href
之后)
$('a').click(function( e ) {
alert(this.id);
// e.preventDefault(); // Uncomment this line if you don't want
}); // to follow the link's href.
最好向链接添加一个class属性,然后选择使用该属性:
$('a').click(function( e ) {
alert(this.id);
// e.preventDefault(); // Uncomment this line if you don't want
}); // to follow the link's href.
$('a.someClass').click(function( e ) {
alert(this.id);
// e.preventDefault(); // Uncomment this line if you don't want
});
这将选择在这里
$('a').click(function( e ) {
alert(this.id);
// e.preventDefault(); // Uncomment this line if you don't want
}); // to follow the link's href.
$('a[id^=read]').click(function(){
alert(this.id);
return false;
});
我使用选择器来定位具有id
且以read
开头的链接
$('a').click(function( e ) {
alert(this.id);
// e.preventDefault(); // Uncomment this line if you don't want
}); // to follow the link's href.