We are about to switch to a new forum software. Until then we have removed the registration on this forum.
how to add placeholder in div created by createDiv() in p5js?
You can check the dom function id(). I suspect you could do something like this (I can't tested at the moment)
var dd=createDiv('Parent DIV'); dd.id('mydiv');
Then in your code, you can grab your div:
var adiv=select(''#mydiv');
Then you have two options:
var xtra=createDiv('Another division'); xtra.parent(adiv); //OR xtra.parent(dd); //In the case dd and xtra are on the same variable scope
More in the p5js.org >> libraries >> dom : select(), parent(), id()
Kf
thanks for suggestion.This makes div inside a div,how to use this concept to adding placeholder text inside the div.
placeholder text
Sample code please? You mean like a paragraph, an HTML component?
var placeholder="start typing"; var div=createDiv(placeholder); div.attribute('contenteditable', 'true');
when we click on div, placeholder text disappears and my typing is shown in the div.
Have you consider input()? Not sure if you can make it multiline.
There is a way to do it using canvas +text() under p5.js but my impression is that you want to stick to HTML elements?
Answers
You can check the dom function id(). I suspect you could do something like this (I can't tested at the moment)
Then in your code, you can grab your div:
var adiv=select(''#mydiv');
Then you have two options:
More in the p5js.org >> libraries >> dom : select(), parent(), id()
Kf
thanks for suggestion.This makes div inside a div,how to use this concept to adding placeholder text inside the div.
Sample code please? You mean like a paragraph, an HTML component?
Kf
when we click on div, placeholder text disappears and my typing is shown in the div.
Have you consider input()? Not sure if you can make it multiline.
There is a way to do it using canvas +text() under p5.js but my impression is that you want to stick to HTML elements?
Kf