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><?php echo $id; ?></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
Post a Comment