Skip to main content

Bug Tracker

Side navigation

#11712 closed bug (invalid)

Opened May 07, 2012 06:20AM UTC

Closed May 07, 2012 12:22PM UTC

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:

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='';" />')

Attachments (0)
Change History (4)

Changed May 07, 2012 07:28AM UTC by anonymous comment:1

use the below.



<script type='text/javascript' src='c:/hitesh/jqueryLatest.js'></script>


$(document).ready(function() {

var $inputBox=$('');






<div id='examplediv'></div>

<input type="text" value="email" onclick="if(this.value='email') this.value='hitesh';"/>



Changed May 07, 2012 10:07AM UTC by sindresorhus comment:2

owner: → 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: Open the link and click to "Fork" (in the top menu) to get started.

Changed May 07, 2012 12:13PM UTC by anonymous comment:3

status: pendingnew

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


Changed May 07, 2012 12:22PM UTC by sindresorhus comment:4

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.