It seems slang to work, for some reasons it does not output my ID like ASP control (Label1) ID script type = "text / javascript" & gt; $ (Function () {$ (document) .ready (function () {$ ('button') Click (function () {var x = $ ('textarea'). Val (); $ ('textarea') .val (''); var label = $ ("# & lt;% = Label1.ClientID%>"); var newdiv = $ ("
"). Html (x) atr ('id', 'test'); $ ('# test1') .andand (nudeve) var serializer = new xml attribute (label); label text (serializer.carializeToString )); Return false;});});}); & Lt; / Script & gt; & Lt; Textarea style = "border: 0" cols = "77" lines = "2" & gt; Write something ... & Lt; / Textarea & gt; & Lt; Button & gt; Post message & lt; / Button & gt; & Lt; ASP: labeled id = "label 1" runat = "server" text = "label" & gt; & Lt; / Asp: label & gt; & Lt; Div id = "test1" & gt; & Lt; / Div & gt; & Lt; / ASP: Content & gt;
Instead of labeling, find out how to set the text of the asap control with my jquery:
& lt; Asp: Label ID = "Label1" run = "server" text = "label" & gt; & Lt; / Asp: Label & gt; Bella who works here - Many of your stuff is wrong in your code, but I stick to start big things then you sort out a few things. $ ('mybutton'). Click (function () {// store text area value var x = $ ('# mytextarea'). Val (); // Clear text field $ ('# mytextarea'). Val (''); // Enter the textarea value in the new div var newdiv = $ ("div> "). Html (x) .attr ('id id (newdiv); // newdiv's html Also get the html = $ ('& lt; div & gt;') attachments (newdiv.clone ()) .remove () .html (); // Save the newdiv's html so that we can see the page But can show escapedhtml = $ (' Your code is most likely the cause of postback because your ASP tag has runat = "server." As you can see in the previous post, If you do not need to use ASP control, instead of relying on ASP controls, type & lt; input type = "button" value = "mybutton" /> directly in your aspx page < / P> Your code is in an anonymous function and it does not need to be. Your code should be executed inside a $ (document) .ready.
Good practice to store jquery variables such as var label = $ ('# label') by using a penny signal then you know that it is a jQuery object . var $ label = $ ('# label') Hope it will take you on your way.
Comments
Post a Comment