插入<a> Into a div generated by a plugin with javascript or jQuery

时间:2015-10-11 06:49:00

标签: javascript jquery html css wordpress

I am working with a plugin that provides IDX data for listings on a WordPress website. The plugin uses jQuery to query a database for information that it displays on the page. The plugin is not very customizable past simple styling and I would like to insert a link to save to favorites

The link for saving to favorites can be found by viewing this page:

http://angelandpatty.com/homes-for-sale-details/8635-La-Entrada-Avenue-Whittier-CA-90605/PW14217291/306/

所有属性详细信息页面都在页面顶部显示“保存到收藏夹”按钮。这是我在检查员身上发现的:

<a data-toggle="modal" data-target="#ihfsaveListing" class="btn btn-primary btn-detail-leadcapture save-listing-btn"> <span class="hidden-xs"> <i class="glyphicon glyphicon-heart fs-12"></i> Save To Favorites </span> <span class="visible-xs fs-12"> Save To<br>Favorites </span> </a>

我假设数据目标是导致按钮采取行动的原因。

我想要做的是找到一种方法将相同的按钮插入属性存根中,或者使用不同的图标(如竖起大拇指或星形)。

可以在以下页面上查看属性存根:

http://angelandpatty.com/homes-for-sale-in-friendly-hills/

我想在#ihf-main-container .col-xs-9

之后找到一种方法来插入它

如果有任何方法可以使用JavascriptjQuery执行此操作,我当然希望知道。

感谢您的所有帮助。我试着寻找这样的情况,但不幸的是

1 个答案:

答案 0 :(得分:0)

您是否在寻找以下答案?

 var button = $('<a data-toggle="modal" data-target="#ihfsaveListing" class="btn btn-primary btn-detail-leadcapture save-listing-btn"> <span class="hidden-xs"> <i class="glyphicon glyphicon-heart fs-12"></i> Save To Favorites </span> <span class="visible-xs fs-12"> Save To<br>Favorites </span> </a>');

 $('#ihf-main-container .col-xs-9:first').after(button);

请参阅:http://api.jquery.com/after/

  

.after(content [,content])   描述:在匹配元素集中的每个元素之后插入由参数指定的内容。

您可能需要根据需要初始化button