Php code echo Jquery a script dont work any idea? -
i tried call jquery script via php echo won't work , don't know do.
i include php code in index.
<?php echo '<script> $( "#hidebutton" ).click(function() { $( "#id='.$id1.'" ).slideup(); }); </script>'; ?> any idea?
#hidebutton= button#id== div + $id1 = id taken database
the index page (include idposthide.php jquery script^ there^
// if post not submitted display them $query = mysql_query("select text, id,liked,dislike post order id desc"); mysql_query ("set character_set_results='utf8'"); while($row = mysql_fetch_array($query)){ $text = $row['text']; $vote = $row['liked'] ; $vote2= $row['dislike']; $id1 = $row['id']; echo '<div id="id='.$id1.'"><div id="myhidebutton"><input id="hidebutton" type="submit" value="hide"></div>'.'<div id="posts">'.'<h3>Κάποιος είπε:</h3>'.''.'<p><b><font size="3px">' . strip_tags($text) . '</font></b>'.' '.' '.'</p>'; echo '<hr>'; include "src/index.php"; include "idposthide.php"; echo'<br></div></div><br>' ; } } ?>
your jquery wrong. should be:
$( "#'.$id1.'" ).slideup(); jquery uses css-selectors. should $("#id") instead of $("#id=id"). if have id in html <attr id="id=xxx">, correct it, ids should not consist of "=".
in addition, button loaded in dom sure? try:
$(function(){ $( "#hidebutton" ).click(function() { $( "#id='.$id1.'" ).slideup(); }); }); and last not least, without echos:
?> <script> $(function(){ $( "#hidebutton" ).click(function() { $( "#<?php echo $id; ?>" ).slideup(); }); }); </script> <?php
Comments
Post a Comment