Change input button's onClick parameter using JavaScript

I'm making an Android Web Application, and I'm using JQuery Mobile. My question is:

Is it possible to change the onClick event's parameter using Javascript? I will be using Ajax post request to get the primary key attribute of my row from the database. And after getting the primary key, I want to set the parameter of the input button's onClick event.

Here's the structure of my program:

<script>
$.ajax({
    type:"POST",
    url:"url.php",
    dataType:"json",
    data:{input:input},
    success: function (result)
    {
        //Set my input button's onclick
    }
});
</script>

Answers


success: function (result)
{
  $("#" + result).click(function () {
    // do something
  });
}

use this

yourelement.addEventListener('click', yourfunction);

or this

yourelement.addEventListener('click', function() {
   //your code here
});

or in jquery

$('yourelement').click(yourfunction)

You can do like this instead:

$('#element').click({id: id}, handleClick);

If, for example, the click handler is somewhere outside the scope:

function clickHandler(ev) {

    var id = ev.data.id;
    // use id

}

Need Your Help

Weird behavior removing elements from a list in a loop in Python

python list

I understand that you can't remove an element from a list if you are currently iterating over that list. What I'm trying to do then is to copy elements from that list that I do NOT wish to remove to

Quit an application using applescript

applescript quit

Whenever i try to quit an application using applescript i get the following error

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.