Advertisement
Guest User

Untitled

a guest
Feb 28th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title></title>
  4. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  5. <script type="text/javascript">
  6. $(document).ready(function () {
  7.  
  8. var dataSet = $("#container").remove(); // just grab the data. could have also types it all on one line, same thing
  9.  
  10. alert("dataSet: " + dataSet.html()); // nothing in my hands
  11. alert("body: (should just be a comment)" + $("body").html()); // nothing up my sleeves
  12.  
  13. var fields = ["email", "phone"]; // targets
  14. for (var i = 0; i < fields.length; i++) { // foreach...
  15. dataSet.find("[name='" + fields[i] + "']").val("Hello World"); // target change the val
  16. alert("worked here: " + dataSet.find("[name='" + fields[i] + "']").val()); // great! it changed the val
  17. alert("but not here: " + dataSet.html()); // except it didnt.
  18. }
  19. dataSet.html("***"); // yet this works,
  20. alert("yet works this way" + dataSet.html());
  21. });
  22. </script>
  23. </head>
  24. <body>
  25.  
  26. <!-- Just here to get this into memory-->
  27. <div id="container">
  28. <div>
  29. <label for="email">eMail</label>
  30. <input type="text" name="email" value="this.doesnt@work.com" id="eMail" disabled="">
  31. </div>
  32. <div>
  33. <label for="phone" >phone</label>
  34. <input type="text" name="phone" value="(555) 800-1212" id="phone" disabled="">
  35. </div>
  36. </div>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement