Currently I'm using something like:
$('.myclass').click(function(){
var msg = $(this).attr('id');
alert(msg)
});
And HTML:
< a href="#" class="myclass" id="101">Link</a开发者_开发问答>
If I need additional parameters how would I read them? Also is the current way I am using the proper way? Originally I was using hidden input fields so it was already a step up. :p
jQuery Events
jQuery .click()
$('.myclass').bind("click", { Param1: "", Param2: 2 }, function(event){
alert(event.data.Param2);
});
you can use bind()
and send additional data to the event handler as event.data
this may not be the best method, but something i have done is to hyphen delineate the id attribute with other params, like id="101-red-420582"
which all three mean different things and can be easily broken down using the split()
function. not the best, per se, but i've done it and it works.
Quick Solution
<p class="msg_head" id="837" rel="a" **till_limit="9"**>Header-1 </p>
and you can refer as
$(this).attr('till_limit');
This is similar solution like define your own ID and refer the element as per your requirement.
精彩评论