Jquery jcrop css更新vline和hline
我正在使用Jcrop插件裁剪图像,但对jQuery没有太多的了解。我需要根据单选按钮选择动态更改选择边界。 css中有一个用于选择边框宽度的属性(.jcrop vline和.jcrop hline)。如果我手动将宽度更改为“10px!重要”,一切正常 现在我想用Jquery更改width属性,但它没有做任何事情,下面是我的一段代码(如果需要更多代码,请告诉我): 原始css:Jquery jcrop css更新vline和hline,jquery,css,jcrop,Jquery,Css,Jcrop,我正在使用Jcrop插件裁剪图像,但对jQuery没有太多的了解。我需要根据单选按钮选择动态更改选择边界。 css中有一个用于选择边框宽度的属性(.jcrop vline和.jcrop hline)。如果我手动将宽度更改为“10px!重要”,一切正常 现在我想用Jquery更改width属性,但它没有做任何事情,下面是我的一段代码(如果需要更多代码,请告诉我): 原始css: .jcrop-vline { height: 100%; width: 1px !important; } .
.jcrop-vline {
height: 100%;
width: 1px !important;
}
.jcrop-hline {
height: 1px !important;
width: 100%;
}
以及我的html文件中的jQuery:
<script type="text/javascript">
$('#size').change(function(){
$('.jcrop-vline').css('width', '10px !important');
alert('Test');
})
</script>
$('#size')。更改(函数(){
$('.jcrop vline').css('width','10px!important');
警报(“测试”);
})
我添加了警报来检查代码是否执行,警报是否有效。但是jcrop vline width属性没有改变。css文件包含在我的html中(否则当我手动更改它时,它将无法工作)。
我的问题是,为什么这不起作用呢?使用jquery覆盖重要内容的方法 1.使用attr:
$('.jcrop-vline').attr('style', 'width: 10px !important;');
2.使用新类
<style type="text/css">
.jcrop-vline {
height: 100%;
width: 1px !important;
}
.jcrop-vline1 {
height: 100%;
width: 10px !important;
}
</style>
$('unique id').removeClass('jcrop-vline').addClass('jcrop-vline1');
4.每项职能
$( '.jcrop-vline' ).each(function () {
this.style.setProperty( 'width', '10px', 'important' );
});
为什么不能覆盖重要的:
!!在同一层次结构级别上,重要信息比任何信息都重要。如果您可以参考给定的站点,您可以获得有关重要信息的知识。有一些方法可以让你忽略重要的事情。可以使用set'attr'或删除旧类或添加新类。我不知道这不能被覆盖。当我取下那块石头的时候!重要的是从原来的css它的作品!但是我不知道是否有理由把它放在css中。我可以尝试设置一个新属性。谢谢你的帮助!问题是,我们无法为同一层次结构中的元素设置重要值,它将不会覆盖它。当您删除!在原始css中很重要,因为存在层次结构问题。
$( '.jcrop-vline' ).each(function () {
this.style.setProperty( 'width', '10px', 'important' );
});