开发者

jquery resizable from attribute

开发者 https://www.devze.com 2023-03-17 17:55 出处:网络
i managed to resize multiple classes $(\'.s\').resizable({ alsoResize: \'.1,.2,.3\' }); but i want to get the alsoresizable objects from the attribute

i managed to resize multiple classes

$('.s').resizable({ alsoResize: '.1,.2,.3' });

but i want to get the alsoresizable objects from the attribute in the main object i resize. how can i get the attribute values there?

i tried:

<script>
开发者_JS百科$(document).ready(function() {
    $( ".resizable" ).resizable({
        maxHeight: 100,
        maxWidth: 162,
        minHeight: 14,
        minWidth: 162,

        alsoResize: "."+$(this).attr('number')+" "
    });
});
</script>

but its not working. can someone help?

here is a jfiddle for testing: Fiddle


You could build up the list with $.each or maybe $.map:

$.map($('your-selector'), function (element) { 
    return '.' + $(element).attr('number'); 
}).join(',')


this works:

js:

$(".res").mouseover(function() {
    //alert($(this).attr("number"));
    $(".res").resizable( "option", "alsoResize", $(this).attr("number") );
    });

$(".res").resizable({
    });

html:

<div id="div" class="a res ui-widget ui-widget-content" number=".b">Test A</div>
<div id="div" class="b res ui-widget ui-widget-content" number=".c">Test B</div>
<div id="div" class="c res ui-widget ui-widget-content" number=".a,.b">Test C</div>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号