javascript - Get sibling div id generated by PHP -


i have html code kind of blog page. below - code of 1 post , height cuts css. many posts on blog page. want see content of particular page clicking "read more" button. div blog content has dynamic id gets database php.

how can change height of div class "blog_article" clicking "read more" button?

i thought of using js/jquery cannot id of "blog_article" div. or maybe there better way this?

<div class="blog_article_wrapper">     <div class="blog_article" id="<?php echo $id; ?>">         <!--some content-->    </div>       <div class="blog_article_read_more">         <button onclick="blogreadmore()">read more</button>     </div>  </div> 

but cannot id of "blog_article" div

why can't you?:

<button onclick="blogreadmore(<?php echo $id; ?>)">read more</button> 

or, if it's string:

<button onclick="blogreadmore('<?php echo $id; ?>')">read more</button> 

then blogreadmore() has reference id:

function blogreadmore(id) {     // use id identify element , modify want } 

conversely, since tagged jquery, can traverse dom button click determine element without needing id @ all. this:

$('.blog_article_read_more button').click(function () {     var article = $(this).closest('.blog_article_wrapper').find('.blog_article');     // whatever article }); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -