javascript - How to find an element attribute through searching for another attribute of that element -


i'm trying access element's attribute value, finding different attribute, name, of same element.

here's code:

<option data-img-src="http://example.com/pic.jpg" value="pool party 21" pdf-data="http://example.com/mypdf.pdf"></option>  <img class="image_picker_image" src="http://example.com/pic.jpg"> 

here's php try src of image, store variable. then, try find element src of image (the stored variable) attribute called data-img-src holds value.

finally, try store found-elements attribute called "pdf-data" string in variable.

pdfbgimage = $('.tab-pane.active div.thumbnail.selected').children('img').attr('src'); pdfurl = $("[data-img-src=pdfbgimage]").attr('pdf-data'); 

i don't believe code right. can help?

you have concatenate first variable second selector

var pdfbgimage = $('.tab-pane.active div.thumbnail.selected').children('img').attr('src'); var pdfurl     = $("[data-img-src='"+pdfbgimage+"']").attr('pdf-data'); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -