[英]Change CSS Style with jquery in following HTML
I am working on one of the asp.net project which uses Drop-down Menus from from Dynamic Drive 我正在使用从Dynamic Drive使用下拉菜单的asp.net项目之一
After using it with asp.net Menu control asp.net automatically adds styles to it. 将它与asp.net一起使用后,菜单控件asp.net会自动为其添加样式。 I want to replace part of CSS Style
using jQuery from the following code. 我想从以下代码中使用jQuery替换CSS Style
一部分。 I would appreciate help in this regards. 在此方面的帮助,我将不胜感激。
<li class="" aria-haspopup="Menu1:submenu:11" role="menuitem" style="position: relative; float: left; z-index: 100;">
<a href="#?PageId=49&Language=en-US" class="popout level1 static" tabindex="-1" style="padding-right: 10px;">MAIN MENU<img style="border:0;" class="downarrowclass1" src="../down.gif"></a>
<ul class="" id="Menu1:submenu:11" style="display: none; position: absolute; top: 28px; left: 0px; visibility: visible; width: 186px;">
<li role="menuitem" class="" style="position: relative;">
<a href="#?PageId=50&Language=en-US&" class="level2 dynamic" tabindex="-1">SUB MENU</a>
</li>
<li role="menuitem" class="" style="position: relative;">
<a href="#?PageId=52&Language=en-US&" class="level2 dynamic" tabindex="-1">SUB MENU/a>
</li>
<li role="menuitem" class="" style="position: relative;">
<a href="#?PageId=51&Language=en-US&" class="level2 dynamic" tabindex="-1">SUB MENU</a>
</li>
</ul>
</li>
I want to change the style value of top: 28px;
我想更改top: 28px;
的样式值top: 28px;
in UL
with id="Menu1:submenu:11"
to top:-58px
; 在UL
, id="Menu1:submenu:11"
至top:-58px
; I am not sure how I can do. 我不确定该怎么办。
HTML code is exact copy of asp.net web form in the browse. HTML代码是浏览器中asp.net Web表单的精确副本。
I am not sure how I can reference to element with id Menu1:submenu:11
using jQuery & over right the whole style property style="display: none; position: absolute; top: 28px; left: 0px; visibility: visible; width: 186px;"
我不确定如何使用jQuery和ID来引用ID为Menu1:submenu:11
元素,并在整个样式属性right右上方style="display: none; position: absolute; top: 28px; left: 0px; visibility: visible; width: 186px;"
All style changes are easy once you know how: 一旦您知道如何进行所有样式更改就很容易:
$('#Menu1:submenu:11').css('top':-58);
See here for a lot more details 看到这里更多的细节
edit 编辑
I just saw that your problem is that you can't access the selector: $('#Menu1:submenu:11')
? 我刚刚看到您的问题是您无法访问选择器: $('#Menu1:submenu:11')
吗? I suggest submitting another question or searching a little more to find this answer. 我建议提交另一个问题或进行更多搜索以找到此答案。
$('#Menu1:submenu:11').style.top = "-58px";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.