0

i have work out with some new facility for disabling button with update panel. here i successfully disable button control and change innertext ob button with this javascript:

<script type="text/javascript">
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
        function BeginRequestHandler(sender, args) {
            document.getElementById('<%=btn_Login.ClientID %>').innerText = "Processing..";
            args.get_postBackElement().disabled = true;
        }
    </script> 

here i just want to make one common function for all update panel which have submit behaviour when user clicks this buttn then it detects post back and disable other all control with submit behaviour and here i just wan to change element class attribute also.

can any one help me...

2 Answers 2

1

Using jQuery

Add a class:

$('selector').addClass("classname")

Remove a class:

$('selector').removeClass("classname")

Changing whole class attribute

$('seletor').attr('class', 'classname');

Using Javascript

Add a class:

document.querySelector('selector').classList.add('classname')

Remove a class:

document.querySelector('selector').classList.remove('classname')

Changing whole class attribute:

document.querySelector('selector').setAttribute('class','classname');
Sign up to request clarification or add additional context in comments.

1 Comment

Note: classList is supported in quite modern browsers, only. Internet Explorer 7-9 don't support this feature. ... see developer.mozilla.org/en-US/docs/Web/API/…
0

You can also add or remove multiple classes $(selector).addClass('class1 class2')

OR

$(selector).removeClass('class1 class2')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.