Issue
<div id="block_msg" style="width:250px;border: solid 1px red;margin: 15px">
<div id="text_msg1">111текст111</div>
<input type="submit" onclick="clickon(**<<<HERE I WANT SEE DIV ID TEXT_MSG1>>>**)" value="Добавить">
</div>
How can I get id="text_msg1"
and put it into onclick
? How?
Solution
this
is the current object, you can than look at the parent and find the divs. This solution is hacky since changing the layout means it will break.
onclick="clickon(this)"
and
function clickon(btn) {
var wrappingDiv = btn.parentNode;
var childrenDivs = wrappingDiv.getElementsByTagName("div");
alert(childrenDivs[0].innerHTML);
}
It would be better to have a class on the div and look for that class.
Answered By - epascarello Answer Checked By - Terry (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.