开发者

jquery setting options after init

开发者 https://www.devze.com 2023-03-08 16:23 出处:网络
I know one can set plugin options, after things are set.But I\'m not quite sure how to do it.So I created a simple jquery UI example, using the draggable(), with zIndex option already set.So, if I cli

I know one can set plugin options, after things are set. But I'm not quite sure how to do it. So I created a simple jquery UI example, using the draggable(), with zIndex option already set. So, if I click the link I created, I want to change the zIndex option to another integer. Here's the link I am work from: http://jqueryui.com/demos/draggable/#option-zIndex

<script>
$(开发者_JS百科function() {

  $( ".dragimgs" ).draggable({ zIndex: 2700 });


});
</script>

<img class="dragimgs" src="someimg.png" />

<a id="clickme">Click To Change zIndex</a>

So the question is how do I reset the zIndex (or any available option), dynamically. I am assuming that a js function or some onclick event can be utilized, but I honestly don't know how.


You can use .draggable( "option" , "optionName" , value ) to change your zIndex

Putting that together with the zIndex it would look like the following...

$("#clickme").click(function() {
    $(".dragimgs").draggable("option", "zIndex", 1000);
});

Example on jsfiddle

0

精彩评论

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

关注公众号