douxianji6181
2017-09-05 12:16
浏览 134

如何在Div按钮中传递ID,它在ajax中必须将Id传递给另一个页面?

below code is in my ajax which I have comment.id which is coming from php as unique id

 html += '<div class="rTableRow1"><div class="rTableHead"><input id="button1" type="button"   value="action !" />' + comment.id +'</div></div>'

As above full data which be shows a table

I require to click action button where it well take to another page with ID

any one have any idea have to pass a ID in Action button which is in my Ajax.

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

1条回答 默认 最新

  • douxian4323 2017-09-05 13:01
    已采纳

    You can add onclick event-attribute to button as below:

    html += '<div class="rTableRow1"><div class="rTableHead"><input id="button1" type="button" value="action !" onclick="location.href = \'http:\\www.yoursite.com'+comment.id+'\'" />' + comment.id +'</div></div>'

    Here, http:\\www.yoursite.com\ can be your URL and append comment.id as you need to pass with URL to redirect.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题