Opened 11 years ago
Closed 11 years ago
#11712 closed bug (invalid)
Onfocus inside Jquery append
Reported by: | anonymous | Owned by: | anonymous |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | manipulation | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When I was trying to append a textbox inside a div using append method, its stops working when I add javascript onFocus eg: below
$('#examplediv').append('<input type="text" value="email" onFocus="if(this.value=='email')this.value=;" />')
Change History (4)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Owner: | set to anonymous |
---|---|
Status: | new → pending |
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.
comment:3 Changed 11 years ago by
Status: | pending → new |
---|
i am new to jquery and dont know to write test cases as u asked. So try the solution. hitesh
comment:4 Changed 11 years ago by
Component: | unfiled → manipulation |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
That code isn't valid. you need to escape the single quotes in the onFocus attribute. You also should NOT do this. You should rather use even handlers. I suggest you ask a question on the forums, IRC #jquery or StackOverflow.
The bug tracker is for verifiable bugs with jQuery Core itself.
use the below.
<html> <head> <script type='text/javascript' src='c:/hitesh/jqueryLatest.js'></script>
<script> $(document).ready(function() { var $inputBox=$();
$('#examplediv').append($('input'))
}); </script> </head> <body> <div id='examplediv'></div> <input type="text" value="email" onclick="if(this.value='email') this.value='hitesh';"/>
</body> </html>