首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Jquery重新定位此标记?

如何使用Jquery重新定位此标记?
EN

Stack Overflow用户
提问于 2011-06-11 17:59:05
回答 3查看 113关注 0票数 0

我想知道我是否能在Jquery上得到你的帮助。注意,我不能修改这段代码中的任何html,因为它是在wordpress中用单独的小部件动态生成的。

我在标记云中有一个标记,类名为" tag -link-169“

代码语言:javascript
复制
<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文本”单击此标记查看投票“。

代码语言:javascript
复制
<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>

有人能帮上忙吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-06-11 18:18:14

您需要选择元素,然后使用insertBefore将其放在正确的位置。然后,您可以使用before插入文本:

代码语言:javascript
复制
$('a.tag-link-169').insertBefore('form.search_form').before('click this tag to see Polls');
票数 3
EN

Stack Overflow用户

发布于 2011-06-11 18:17:20

试试这个:

代码语言:javascript
复制
$('a.tag-link-169').insertBefore('.search_form').before('click this tag to see Polls');
票数 1
EN

Stack Overflow用户

发布于 2011-06-11 18:17:33

代码语言:javascript
复制
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('');
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6315254

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档