How do I get the string ‘unenable-item’ assuming that it is used as part of the string in a selector such as:
$('.unenable-item').click(function(){
alert($(this).val());
});
thx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Or more generic way
In this case you will get
.unenable-itemand you must work with that string and get substring that you want.EDIT:
.selectorproperty can’t work with$(this)and will return always empty string, because it making new object every time. So I find solution to work with that. The solution is to make new function for binding events and use that function instead of simple jquery functions.Usage
And after this you can simply get your selector
Note, that I used
addEventmethod for binding click, instead of immediately binding by Jquery’sclickfunction.You can see example in jsfiddle http://jsfiddle.net/DFh7z/21/