Jonuux
Jonuux

Reputation: 531

Add text value to jquery function (var)

How can I add input text variable(value) to function(var description) ?

$(".update").click(function()
{
var article_id=$(this).attr("article_id");
var description=$(this).attr("description");
$.ajax
({
type: "POST",
url: "conf.php",
    data: {
    article_id: article_id,
    description: description,
    },..

<a href="javascript:;" class="update" article_id="$id">Description</a><input type="text"></input>

Upvotes: 0

Views: 78

Answers (2)

mplungjan
mplungjan

Reputation: 177965

You mean

$(".update").click(function(e) {
  e.preventDefault(); // do not follow the link
  var article_id=$(this).attr("article_id");
  var description=$(this).next("input").val();

Upvotes: 3

Hackableweb
Hackableweb

Reputation: 372

Try as follow,

var description=$(this).attr("description") + $(this).siblings('input[type=text]').val();

Upvotes: 1

Related Questions