Chud37
Chud37

Reputation: 5007

jquery click select and enable/disable input button

I have several forms with select/input buttons on one page. I want to click on a select form, get the id of it, and toggle disable on a button with the same name except its a class not an id.

my code so far:

$("#main").on("click",".list", function () {
        var j = $(this).attr("id");
        if(j) {alert(j);}
        $("."+j).attr('disabled','disabled');
    });

I cannot seem to reference anything with "."+j any ideas?

<h2>Towns / Suburbs</h2>
        <form method="POST" action="">

        <select class="list" name="data_change" id="towns" size=10>
            <option>foo</option><option>bar</option>
        </select>

        <div class="buttonGroup">
<input type="submit" class="button" name="Delete" value="Delete">
<input type="submit" class="button" name="Add" value="Add">
<input type="submit" class="button" name="Edit" value="Edit" class="towns">
</div>
        </form>

Upvotes: 1

Views: 870

Answers (1)

Jashwant
Jashwant

Reputation: 28995

You cannot have two class attribues, If you have more than one class, separate them with space.

<input type="submit" class="button towns" name="Edit" value="Edit" />

Upvotes: 3

Related Questions