2

I'm targeting this div to add HTML after (using jQuery after) this:

<div class="wpv-setting-container wpv-setting-container-horizontal wpv-settings-layout-markup js-wpv-settings-layout-extra">

For some reason due to technical requirements of the application, I'm forced to use the class wpv-settings-layout-markup. However, there is also another div that contains this class but its hidden:

<div style="display:none;" class="wpv-settings-templates wpv-setting-container wpv-setting-container-horizontal wpv-settings-layout-markup" id="attached-content-templates">

Now when I use the class name in my jQuery after method, it is added to BOTH the visible and invisible div.

$(".wpv-settings-layout-markup").after('data here');

How can I revise this selector:

$(".wpv-settings-layout-markup")

To target only the visible div? Thanks a lot.

4

2 回答 2

7

使用:visible选择器

$(".wpv-settings-layout-markup:visible")

更多信息可以在这里找到:http: //api.jquery.com/visible-selector/

于 2013-08-14T10:38:49.893 回答
0

使用:visible选择器

$(".wpv-settings-layout-markup:visible")
于 2013-08-14T10:39:08.893 回答