Just try this
var previousStyle = $(".mydiv").attr('style')
$(".mydiv").attr('style', 'width:' + $(".image").width() + '!important; ' + previousStyle + '');
Important Attribute
$(document).ready(function () {
var previousStyle = $(".mydiv").attr('style')
$(".mydiv").attr('style', 'width:' + $(".image").width() + '!important; ' + previousStyle + '');
})
check
<html>
<head>
<title>Important Attribute</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var previousStyle = $(".mydiv").attr('style')
$(".mydiv").attr('style', 'width:' + $(".image").width() + '!important; ' + previousStyle + '');
})
</script>
</head>
<body>
<div class="mydiv" style="border: 1px solid black; width: 200px">check</div>
<div class="image" style="width: 280px"></div>
</body>
</html>
if you inspect and see the mydiv attributes you can see the width and important tag, as stated from the jquery statement