javascript - How to select/unselect picture on website? -


i have few images on site , want give user possibility select of them.

i'm trying jquery:

pic.attr('selected', 'selected'); pic.removeattr('selected'); 

my problem how check (properly) pictures (let's assume they're my-pic class) checked.

you can try this:

$('.mp-pic').each(function(i, obj) {    if(obj.hasattribute('selected')) {       // selected     } else {       // not selected     } }); 

or check whether element has particular attribute or not try this:

var attr = $(selector).attr('selected'); if (typeof attr !== typeof undefined && attr !== false) {     // operation } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -