Bug Tracker

Opened 7 years ago

Closed 7 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 7 years ago by anonymous

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>

comment:2 Changed 7 years ago by sindresorhus

Owner: set to anonymous
Status: newpending

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 7 years ago by anonymous

Status: pendingnew

i am new to jquery and dont know to write test cases as u asked. So try the solution. hitesh

comment:4 Changed 7 years ago by sindresorhus

Component: unfiledmanipulation
Priority: undecidedlow
Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.