1

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>
1
  • it alerts fine, I get 'towns', but then with '.'+j i get nothing.. :( Commented Jul 4, 2012 at 14:05

1 Answer 1

3

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" />
Sign up to request clarification or add additional context in comments.

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.