douqiju2520
douqiju2520
2018-07-24 22:07
浏览 54

html Popover引用和引号错误的位置?

Im having an issue with the structure of a popover. When the popover is structured like the below, it flows as designed but Im missing an ID in the onclick function.

<td align="center"><input type="image" data-placement="left" data-toggle="popover" style="height:25px; width:25px" src="<?php echo ABSPATH; ?>/uploads/settings_icon.png" data-content='<a style="cursor: pointer;" onclick="test();">Delete</a>' ></td>

When I add the missing ID into the onclick function as mentioned, it breaks the button. Please see the below code...

<td align="center"><input type="image" data-placement="left" data-toggle="popover" style="height:25px; width:25px" src="<?php echo ABSPATH; ?>/uploads/settings_icon.png" data-content='<a style="cursor: pointer;" onclick="test(**'<?php echo $id;?>'**);">Delete</a>' ></td>

This is the outcome of the above line... Any help would be greatly appreciated.

Image here

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

2条回答 默认 最新

  • dongliufa6380
    dongliufa6380 2018-07-24 22:23
    已采纳

    You need to escape your quotes inside the test() function call. You're already inside some single quotes that are used for the data-content attribute you're defining. When you use your first single quote inside the test() call, you're effectively ending the data-content attribute.

    This question might help you further.

    点赞 评论
  • dongmu3187
    dongmu3187 2018-07-24 22:24

    I don't think that it is necessary to echo $id within quotes. Try:

    <td align="center"><input type="image" data-placement="left" data-toggle="popover" style="height:25px; width:25px" src="<?php echo ABSPATH; ?>/uploads/settings_icon.png" data-content='<a style="cursor: pointer;" onclick="test(**<?php echo $id;?>**);">Delete</a>' ></td>
    
    点赞 评论

相关推荐