1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

click not working

Discussion in 'JavaScript' started by neilfurry, Jul 13, 2016.

  1. #2
    hi,
    can you help... i need this line to get working

    https://jsfiddle.net/hj3sm9u7/1/

    it should fire up an alert whenever a button is clicked. but it doesnt work.

    thank you
     
    Last edited by a moderator: Jul 13, 2016
    neilfurry, Jul 13, 2016 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #3
    You have your fiddle set up for pure javascript but your code is for jquery.

    Do you want a jquery solution?
     
    sarahk, Jul 13, 2016 IP
  3. fehtrar

    fehtrar Active Member

    Messages:
    11
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    80
    #4
    As Sarahk said, you need to choose to use javascript or jquery to navigate the dom.
    In your fiddle you use jquery selector but didn't include the jquery plugin itself.
    But for that small functionality, you don't need to use jquery, just use javascript dom element http://www.w3schools.com/js/js_htmldom_elements.asp .

    Also, for the alert function, the argument is a string. Ref: http://www.w3schools.com/jsref/met_win_alert.asp
     
    fehtrar, Jul 13, 2016 IP
  4. neilfurry

    neilfurry Active Member

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #5
    yes, it is for jquery... there is different behavior on clone method used.

    The click doesnt seem to work here

    https://jsfiddle.net/hj3sm9u7/5/

    im trying to delete a row from the table.
     
    neilfurry, Jul 13, 2016 IP
  5. neilfurry

    neilfurry Active Member

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #6
    so when you click on "[X]", that row should be removed.
    but the click doesnt seem to work.

    https://jsfiddle.net/hj3sm9u7/5/
     
    neilfurry, Jul 13, 2016 IP
  6. fehtrar

    fehtrar Active Member

    Messages:
    11
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    80
    #7
    This doesn't work because the dom with 'delrow' class are not created yet unless you add one row , so can't track the onClick event yet.
    The best way is to add the event listener(onClick) in the adding row event
    I updated your fiddle: https://jsfiddle.net/hj3sm9u7/6/
     
    fehtrar, Jul 14, 2016 IP