jquery

Search comma-separated list attribute using jQuery

I have an attribute that is comma-separated list, and I want to search for a particular value in that list example: <img id=”img1” src=”somepic.jpg” tags=”nature,flower,color”> SOLUTION Using jQuery, it’s simple to do, for example, I will search for the tag “nature” in the image var exists = $.inArray(“nature”, $(“#img1”).attr(“tags”).split(‘,’)) != -1;

Search comma-separated list attribute using jQuery Read More »

Get radio group value with Jquery

Assume you have one radio group name default_lang and you want to know which one is selected <input name=”default_lang” value=”en” type=”radio” /> <input name=”default_lang” value=”fr” type=”radio” /> <input name=”default_lang” value=”de” type=”radio” /> Well, it’s easy with jQuery var default_lang = $(‘input:radio[name=default_lang]:checked’).val();

Get radio group value with Jquery Read More »