jquery - Get this form's attributes on a form submit even handler function -


I want to be able to get a form attributes ( url attribute), and submit it Save as a variable but I'm having problems getting value from the comments box too.

Here's my form in HTML:

  & lt; Form class = "comment_form" action = "" Url = "comments / 12/3 / sequence" method = "post" & gt; & Lt; Textarea name = "commentField" & gt; Write your comment here ... & lt; / Textarea & gt; & Lt; P align = "center" & gt; & Lt; Input type = "submit" class = "form-button" value = "submit comment" /> & Lt; Input type = "button" class = "form-button" value = "cancel" /> & Lt; / P & gt; & Lt; / Form & gt;   

This is my current JavaScript:

  $ ('. Comment_form'). Submit (function () (warning ("work!"); / / "Work!" Var urlAttr = $ (this) .attr ("url"); // wants to get the 'url' included in the form tag. Warning (urlAttr); // undefined var dataString = 'comment =' + $ ("Textarea #"). Price (); // Want to get everything from comment box alert (datastring) // no message here .});   

Thanks for your help

working jsfiddle:

You were finally missing a semicolon alert (datestring) of

no .value () in jQuery That's why I also changed the $ ('textarea'). Value () to $ ('Textera'). Html () , but $ ('textarea'). Val () will also work

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -