2012-05-02 22 views
7

में काम नहीं कर रहा मैं मेरी asp.net MVC के दृश्य के अंदर निम्न स्क्रिप्ट: -प्रोप ("अक्षम", सत्य); और attr ('अक्षम', 'अक्षम') क्रोम और फ़ायरफ़ॉक्स

function disableform(id) { 
    $('#' + id).prop("disabled", true); 
} 

लेकिन इसके बाद के संस्करण समारोह केवल तत्वों को निष्क्रिय कर देगा इंटरनेट एक्सप्लोरर का उपयोग करके, लेकिन क्रोम या फ़ायरफ़ॉक्स पर काम करने में असफल हो जाएगा, मैंने .prop("disabled", true); के बजाय attr('disabled', 'disabled') लिखने की भी कोशिश की, लेकिन इसने समस्या को हल नहीं किया।

मेरी Jquery संस्करण 1.7.1

तो क्या समस्या हो सकती है है?

बीआर

+2

पर काम करता है तो आप इस डाल दिया उस फ़ंक्शन में, आपको क्या मिलता है: 'अलर्ट ($ (' # '+ id)। लम्बाई) ' –

+0

दोनों क्रोम में ठीक काम करने लगते हैं: http://jsfiddle.net/Fuw49/ –

उत्तर

8

एक रूप अक्षम करना गलत है! आईई बस इसे गड़बड़ कर रहा है! आपको फ़ील्ड अक्षम करना चाहिए।

function disableform(id) { 
    $('#' + id+' :input').prop("disabled",true); 
}​ 

DEMO

1

मैं ASP.NET चलाने के लिए और यह एक ही मुद्दा था।

मैंने jquery को हटा दिया और शुद्ध जावास्क्रिप्ट पर गया और यह बहुत अच्छा काम किया।

var element = document.getElementById('MyID'); 
    element.setAttribute('disabled', 'disabled'); 

संपादित करें: इसके लिए ठीक से काम करने के लिए आपको element.removeAttribute ('अक्षम') का उपयोग करना होगा; तत्व सक्षम करते समय। अन्यथा यह अक्षम रहता है।

-1
function SwapA(SwapActivation) { 
for (i=1;i==5;i++) { 
if (i != SwapActivation) { 
    // All Browsers supported ..... 
    $("input[name=pg1"+i+"]").prop('disabled', true); 
    $("input[name=pg2"+i+"]").prop('disabled', true); 
} 
else { 
    // JQuery 1.10+ _&&_ Opera 12 and All other browsers... !!!! 
    if ($("input[name=pg1"+i+"]").prop('disabled') === true) 
     $("input[name=pg1"+i+"]").prop('disabled', false); 
    if ($("input[name=pg2"+i+"]").prop('disabled') === true) 
     $("input[name=pg2"+i+"]").prop('disabled', false); 

    // works = JQuery 1.10+ _&&_ Opera 12.16 + Firefox 24; 
    // do not work "Opera 17.0.1241.53", "Chrome" v.30.0.1599.101 m 
    $("input[name=pg1"+i+"]").removeProp('disabled'); 
    $("input[name=pg2"+i+"]").removeProp('disabled'); 
    // .removeProp() is affects negative 

    // works possible = JQuery 1.4.x : 
    $("input").attr('name','pg1'+i)[0].removeProp('disabled'); 
    $("input").attr('name','pg2'+i)[0].removeProp('disabled'); 
}}} 

उपयोगी है? :)

0

मैं इसे क्रोम में काम करने के लिए संपत्ति को हटाने नहीं मिल सका, तो मैं बस विकलांग वर्ग कहा, यह एक सच्चे विकलांग नहीं है बल्कि यह IE और क्रोम

$('#search').on('click', function (event) { 
    $('#search').text("Searching"); 
    $('#search').addClass("disabled"); 
    return true; 
}); 
संबंधित मुद्दे