2016-02-25 23:15
浏览 52


This successfully gives an alert for the current clicked link's ID.

jQuery('a.inline').live('click',function() {
 jQuery(this).attr('href', 'javascript:void(0)');

However, instead of getting an alert, i was it to update a variable on that page that i can echo. For example i would like to use something like this ...

<p><?php echo $theechoedid; ?></p>

I don't really want to be able to echo this as a value of a div, as i'll be using the echo'd value in a loop like so:

<?php $loop = new WP_Query( array( 'p' => '424', 'post_type' => 'product', 'posts_per_page' => 1 ) ); ?>

Thanks for your help guys.

图片转代码服务由CSDN问答提供 功能建议


 <  code> jQuery('a.inline')。live('click',function(){
 alert(this。  id); 

然而,我没有收到警报,而是更新了该页面上我可以回应的变量。 例如,我想使用这样的东西......

 &lt; p&gt;&lt;?php echo $ theechoedid;  ?&gt;&lt; / p&gt; 

我真的不想将此作为div的值回应,因为我将使用 循环中的echo'd值如下:

 &lt;?php $ loop = new WP_Query(array('p'=&gt;'424','post_type'  =&gt;'product','posts_per_page'=&gt; 1));  ?&gt; 


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • duancong7358 2016-02-26 00:41

    If I understand the question correctly, you don't actually need php for this. Just use javascript to change the content.

    Add an id to the html so it's easier to grab ..

    <p id="id-goes-here"></p>

    .. then change it.

    jQuery('a.inline').live('click',function() {
        jQuery(this).attr('href', 'javascript:void(0)');
        jQuery( "#id-goes-here" ).html( this.id );
    点赞 打赏 评论
  • douyue8364 2016-02-26 00:47

    Link 1 Link 2

    $(function() {
      $('.temp).bind('click', function() {

    This should work.


    点赞 打赏 评论
  • dpdhf02040 2016-03-01 16:36

    I had to use an Ajax call in the end. Thanks for everyones help though.

    点赞 打赏 评论

相关推荐 更多相似问题