javascript - Get image url inside li -


i've code

<li>     <div class="product-container">         <div class="product-imgs">             <img src="https://xxxx.png">         </div>         <div class="product-desc product-desc-top">             <h3>kitten 1</h3>             <p class="title-desc">this kitten kitten kitten kitten kitten kitten</p>         </div>         <div class="product-desc product-desc-bottom">             <h4>$ 999</h4>             <p class="count-buyers">1 buyer</p>         </div>     </div> </li> 

i have lot of <li>, , condition wanted this:

if click on <li> want img url. wanted h3, p, h4, p content.




possible handle condition using jquery?

thanks

try it:

// image url , tags clone.

 $(function() {            $("li").click(function(){                 var imgurl = $(this).find("img").attr("src");                 var h3 = $(this).find("h3").clone();                 var h4 = $(this).find("h4").clone();                 var title_desc = $(this).find(".title-desc").clone();                 var count_buyers = $(this).find(".count-buyers").clone();             })         }); 

// image url , text on tags.

$(function() {            $("li").click(function(){                 var imgurl = $(this).find("img").attr("src");                 var h3 = $(this).find("h3").text();                 var h4 = $(this).find("h4").text();                 var title_desc = $(this).find(".title-desc").text();                 var count_buyers = $(this).find(".count-buyers").text();             })         }); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -