Javascript 如何使用jquery查找div的下一个跨度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14752375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 17:47:23  来源:igfitidea点击:

how to find next span to div using jquery?

javascriptjqueryasp.netcss

提问by Ram

I have a divand a spannext to it i just want to give it topusing jquery how can i do it. both divand spanare generating dynamically. Div has id "divTest" i want to find next span to this div. I have tried some tricks but didnt succeed yet.

我在它旁边有一个div和一个跨度,我只想使用 jquery将其置于顶部,我该怎么做。既DIV跨度被动态地生成。Div 的 id 为“ divTest”,我想找到这个 div 的下一个跨度。我尝试了一些技巧,但还没有成功。

Updated:

更新:

Actually i have implemented the Password Strength on a page. and i want to change the position of that. I am pasting the html rendering in browser

实际上我已经在页面上实现了密码强度。我想改变那个位置。我在浏览器中粘贴 html 渲染

    <input id="main_cntrlChangePwd_txtNewPassword" class="feild" type="password" maxlength="300" name="ctl00$main$cntrlChangePwd$txtNewPassword">
<div id="PasswordStrengthBorder" style="position: absolute; display: inline; height: 3px; top: 95px; left: 445px; border-style: solid; border-width: 1px; padding: 2px; width: 200px;"></div>
<div id="PasswordStrengthBar" class="BarIndicator" style="position: absolute; display: inline; height: 5px; top: 97px; left: 447px; width: 75px; background-color: blue;"></div>
<span style="position: absolute; top: 105px; left: 445px; font-size: 75%; display: inline-block;
 width: 240px;">5 more characters, At least 2 more numbers, 1 more symbol, 1 Upper case characters</span>
<br>
<span id="spNewPwd" class="imp_msg error_msg">Message</span>
</div>

Thats all

就这样

回答by Curt

Use jQuery next():

使用 jQuery next()

$("#divTest").next("span").css("top", "10px"); 

Live Demo:http://jsfiddle.net/YUNXa/

现场演示:http : //jsfiddle.net/YUNXa/

回答by AdityaParab

like this?

像这样?

$("#divTest").next();

Or you can also try

或者你也可以试试

$('#divTest').nextAll('span:first');

回答by Salman

May be this is what you need

可能这就是你需要的

$('#divTest').next('span')

$('#divTest').next('span')