how to access to the php content of a html tag in jQuery? -


this question has answer here:

i know how access php content of html tag in jquery. explanation below:

this html code:

<div id="edittitle" title="editing title"> <b><?php $id="a"; ?></b> </div> 

and jquery code:

$("#table_child_title").on("click", ".editlink", function(event){ var string2=$("#edittitle" ).children('b').contents(); alert(string2); }); 

what want when executing line alert(string2); alert window shows me between <b> , </b>. in other words, shows message below:

<?php $id="a"; ?> 

is possible in jquery? if yes, wrong in code , right one?

thanks in advance.

first must echo php variable:

<div id="edittitle" title="editing title"> <b>&lt;?php echo $id; ?&gt;</b> </div> 

the use .text() or .html() contents:

var string2=$('#edittitle').children('b').text(); console.log(string2); 

you should not use alert() troubleshooting., use console.log() instead.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -