更改div Jquery或CSS的名称 [英] Change the name of a div Jquery or CSS
问题描述
我的DOM中有这个div
i have this div in my DOM
<div class="span4 minus65" id="divChange">
我已经给它一个id,所以我可以选择它与jquery希望
I have given it an id so that i can select it with jquery hopefully
我想要做的是将div更改为
What i want to do is change the div to
<div class="span12" id="changeBack">
当屏幕尺寸低于600px例如(我已经设置id = changeback为im猜测病需要还原它吗?)Im学习jquery所以会欣赏一些指针,在这里做什么使这发生或有一种方式使用CSS媒体查询?
when the screen size gets below 600px for example (I have set the id=changeback as im guessing ill need to revert it back?) Im learning jquery so would appreciate some pointers on what to do here to make this happen or is there a way to use CSS media queries? (None than i can think of though)
任何帮助感谢
推荐答案
p>这样的东西应该工作。您应该查看CSS 3媒体查询,因为它们可能会帮助您在不涉及JavaScript的情况下完成您的任务。
Something like this should work. You should take a look at CSS 3 Media Queries as they might help you in accomplishing your task without involving JavaScript.
$(window).resize(function(){
if($(window).width() < 600 && $("#changeBack").length == 0){
$("#divChange").attr("id", "changeBack");
}
else{
$("#changeBack").attr("id", "divChange");
}
});
这篇关于更改div Jquery或CSS的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!