---
title: "Change attributes of a DOM element when it appears"  
description: "Change attributes of a DOM element when it appears"  
author: "Anonymous User"  
published: 2013-04-05  
updated: 2013-04-05  
canonical: https://www.mindstick.com/forum/717/change-attributes-of-a-dom-element-when-it-appears  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Change attributes of a DOM element when it appears

Hi All!\
Is there a way to change the [attribute](https://www.mindstick.com/blog/221/attributes-reflection) of a [DOM](https://www.mindstick.com/blog/304003/what-is-the-difference-between-virtual-dom-and-shadow-dom) element as it is created? I have an [input](https://www.mindstick.com/forum/159209/how-can-i-read-convert-an-input-stream-into-a-string-in-java) (has an ID) that is created by a plugin. I need to change the \
[placeholder](https://www.mindstick.com/forum/1519/how-do-i-remove-a-listbox-new-item-placeholder) of that input when it appears.\
i.e.\
$("#token-input_sample").live("attr","placeholder","place");[Code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) above doesn't work.\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by Vijay Shukla

Hi Ankita!\
modify your condition as below\
var $input = $('#token-input_sample');\
if($input.length > 0) $input.prop('placeholder', 'place');\

### Reply by AVADHESH PATEL

Hi Ankit!\
Try this way, i hope it solve your problem!\
$('#token-input_sample').prop('placeholder', 'place');


---

Original Source: https://www.mindstick.com/forum/717/change-attributes-of-a-dom-element-when-it-appears

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
