我想知道我是否能在Jquery上得到你的帮助。注意,我不能修改这段代码中的任何html,因为它是在wordpress中用单独的小部件动态生成的。
我在标记云中有一个标记,类名为" tag -link-169“
<a style="font-size: 1.3em; color: rgb(30, 37, 130);" title="1 topic" class="tag-link-169" href="http://blahblahblah.com/tag/poll-2/">poll</a>它的父类是<div class="tagcloud">
我希望将特定的标记" tag -link-169“从标记云中移除,并将其放在搜索框的前面,搜索框中有一个类为"search_form",还可以在标记前面添加一个html文本”单击此标记查看投票“。
<form action="http://blahblah.com/" class="search_form" method="get">
<p>
<input type="text" onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}" onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}" id="s" name="s" value="To search, type and hit enter" class="text_input">
<input type="hidden" value="Search" id="searchsubmit">
</p>
</form>有人能帮上忙吗?
发布于 2011-06-11 18:18:14
您需要选择元素,然后使用insertBefore将其放在正确的位置。然后,您可以使用before插入文本:
$('a.tag-link-169').insertBefore('form.search_form').before('click this tag to see Polls');发布于 2011-06-11 18:17:20
试试这个:
$('a.tag-link-169').insertBefore('.search_form').before('click this tag to see Polls');发布于 2011-06-11 18:17:33
use .find( classname ) select DOM particular tag having classname.
<div class="parenttoform"
<form action="http://blahblah.com/" class="search_form" method="get">
<p>
<input type="text" onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}" onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}" id="s" name="s" value="To search, type and hit enter" class="text_input">
<input type="hidden" value="Search" id="searchsubmit">
</p>
</form>
</div>
// jquery
$('.parenttoform') .append('');
// here what to append, need html right?
//either you can create new html or give parrent div to link like below
<div class="tag-link-169"><a style="font-size: 1.3em; color: rgb(30, 37, 130);" title="1 topic" href="http://blahblahblah.com/tag/poll-2/">poll</a></div>
now on tag click,
add first and then remove
//jquery
$('.parenttoform') .append($('.tag-link-169').html());
$('.tag-link-169').html('');https://stackoverflow.com/questions/6315254
复制相似问题