jquerysmart-wizard

How to remove an element's attribute/class after page load using jquery if the attribute is being added by another script(Smartwizard plugin)


I am using a jquery plugin (smartwizard) to make a form wizard. The plugins automatically adds an attribute called "isdone" and a class called "done" on all links that appears in the form. This helps the plugin to know which form steps are completed. But it makes other links in the form malfunction due to the added classes. I want to remove the class and the attribute from some links.

I have this link:

<a href="sample.com" id="file_link">My link</a>

after page load the plugin adds the following attribute and class

<a href="sample.com" class="done" isdone="1" id="file_link">My link</a>   

Here is the code snippet that initializes the wizard, and what i tried:

jQuery(document).ready(function(){
 jQuery('#wizard').smartWizard({
 selected:1,
 enableAllSteps:false,
 transitionEffect:'slideleft',
 onLeaveStep:leaveAStepCallback,
 onFinish:onFinishCallback,
 onContinueLater:onContinueLaterCallback,
 enableFinishButton:false,
 });
 //
jQuery('#file_link').removeAttr('isdone');//doesn't work
    jQuery('#file_link').live(function(){
    jQuery(this).removeAttr('isdone');//doesn't work also
});
});

Any Ideas on how to solve this?


Solution

  • Add the code into document ready function.

    $(document).ready(function()
    {
        setTimeout(function() {
            var myAttr = $('#file_link').attr('isdone');
            if (typeof myAttr !== 'undefined' && myAttr !== false) {
                $('#file_link').removeAttr('isdone');
            }
        }, 250);
    });