1

It could be a rookie mistake, but I've gone over my code enough times doing things such as; pre-pending .select-delete with div, attempted to use document.write("Hello") to see if the event was firing or not.

Here's a link to my jsFiddle: http://jsfiddle.net/gPF8X/5/

I really have no idea what's going on :(.

Any help would be greatly appreciated!

Edit: Linked to the incorrect JSFiddle, relinked to the correct one.

Avicinnian
  • 1,802
  • 4
  • 34
  • 53

3 Answers3

2

There is no - in your div class name.

<div id="1" class="selectdelete"></div>

$('.select-delete').click( function() {

Got it - id needs to be wrapped in quotes.

var value = $(this).attr('id');
marissajmc
  • 2,535
  • 1
  • 19
  • 19
  • FYI, an HTML ID cannot start with a number. See this question for details: http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html – Zach Rattner Oct 17 '11 at 05:32
1

The trigger is firing, but your code is not running because of an error - you're not quoting the string 'id' so it's an undefined value. Use your browser's debugger tool - it will help for this sort of thing.

Beyond that though, I can't say anything further because it's not clear what the desired result is.

Edit There's another issue as well - the selector is not working. You can't use the [ and ] character unquoted inside a jQuery comparison like that. The simplest solution is just not to have those characters in your input names. But you can also use escaping like so: $('select[name=g_country\\['+value+'\\]]').

Dan
  • 10,380
  • 4
  • 46
  • 74
0

I know you already accepted my other answer, but I just want to add for the record that there is another way to do it. Specifically, this seems like one of those cases where jQuery is less helpful rather than more. What I would do is change your HTML so the element names were also given as IDs, and then write it like so:

document.getElementById('g_country['+value+']').disabled = true;
document.getElementById('g_url['+value+']').disabled = true;
Dan
  • 10,380
  • 4
  • 46
  • 74