使用jquery禁用/启用div [英] Disabling/Enabling div using jquery

查看:455
本文介绍了使用jquery禁用/启用div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对jQuery相对来说比较新。

 < div data-rle =content我的工作是创建一个接收NGO捐款的应用程序。 ID = 保存 > 
< label for =saveWidget>在网上发布前保存您的Widget:< / label>
< input type =submitvalue =Save Widgetid =saveWidget
data-theme =bdata-inline =true/>
< / div>
< div data-rle =contentid =post>
< fieldset data-role =controlgroup>
<图例>选择发布您的在线选项:< / legend>
< input type =radioname =submitid =htmlvalue =hmtl
checked =checked/> < label for =html>请提供
的HTML - 我会自行发布。 < br>将在下面显示HTML
。< / label>
< input type =radioname =submitid =blogvalue =blog/> < label
for =blog>转到Blogger< / label>
< / fieldset>
< input type =submitvalue =Get HTMLid =submitWidget
data-theme =bdata-inline =true/>
< / div>

我的目标是让div与 id =post在开始时被禁用,当用户点击保存时,我想启用div。我尝试使用 $('#post')。attr('disabled',true); 但它似乎不起作用。该div不会被禁用
关于如何实现这一点的任何想法。

解决方案

也许是这样的: http://jsfiddle.net/MTQzD/

文档准备就绪时,禁用 #post 中的所有输入。同时在你的css中给你#post一个你选择的颜色(例如lightGray)。

然后当点击Save Widget时,启用输入并移除#post div的颜色。

  $(document).ready(function(){
$('input [type = radio]') .attr('disabled',true);
$('#submitWidget')。attr('disabled',true);
});

$(#saveWidget)。click(function(){
$('input [type = radio]')。attr('disabled',false);
$('#submitWidget')。attr('disabled',false);
$('#post')。css(background-color,#EAEAEA);
}) ;


I am relatively new to jQuery. I am working on an application to create a widget for accepting donations for NGO.

<div data-rle="content" id="save">  
<label for="saveWidget">Save your Widget before posting in online:</label>  
<input type="submit" value="Save Widget" id="saveWidget"
data-theme="b" data-inline="true" />  
</div>  
<div data-rle="content" id="post">  
<fieldset data-role="controlgroup">  
    <legend>Select on option for posting your online:</legend>  
    <input type="radio" name="submit" id="html" value="hmtl"
    checked="checked" /> <label for="html">Please provide
    the HTML - I'll post it myself. <br>The HTML will be
    displayed below.</label>   
            <input type="radio" name="submit" id="blog" value="blog" />   <label
    for="blog">Go to Blogger</label>  
</fieldset>  
<input type="submit" value="Get HTML" id="submitWidget"
data-theme="b" data-inline="true" />  
</div>

My goal is to have the div with id="post" disabled in the start, and when user clicks on save I want to enable the div. I tried using $('#post').attr('disabled', true); but it does not seem to work. The div does not get disabled Any ideas on how to achieve this.

解决方案

maybe something like this: http://jsfiddle.net/MTQzD/?

When document is ready disable all inputs in #post. Also give #post a color of your choice in your css (e.g. lightGray).
Then when "Save Widget" is clicked, enable the inputs and remove the color of the #post div.

$(document).ready(function() {
    $('input[type=radio]').attr('disabled', true);
    $('#submitWidget').attr('disabled', true);
});

$("#saveWidget").click(function() {
    $('input[type=radio]').attr('disabled', false);
    $('#submitWidget').attr('disabled', false);
    $('#post').css("background-color", "#EAEAEA");
});

这篇关于使用jquery禁用/启用div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆