how to find div ID on click using jquery
Solution:
<script>
var coutnet=0;
function creatediv() {
counter = counter + 1;
var x = $("<div class='droppable' id='D" + counter + "' onclick='findid(this)'> </div>");
$("div#maindiv").append(x);
function findid(el) {
var idss= $(el).attr('id');
alert(idss);
}
</script>
<h2>
html code
<input onclick="creatediv()" type="button" value="createnewdiv" />
<br />
html code
<img class="droppableimg" id="xyz" onclick="findid(this)" />
javascript
<script type="text/javascript">
function findid(el) {
var idss= $(el).attr('id');
alert(idss);
}
</script>
<script>
var coutnet=0;
function creatediv() {
counter = counter + 1;
var x = $("<div class='droppable' id='D" + counter + "' onclick='findid(this)'> </div>");
$("div#maindiv").append(x);
function findid(el) {
var idss= $(el).attr('id');
alert(idss);
}
</script>
<h2>
html code
<input onclick="creatediv()" type="button" value="createnewdiv" />
<br />
how to find image id on click using jquery
html code
<img class="droppableimg" id="xyz" onclick="findid(this)" />
javascript
<script type="text/javascript">
function findid(el) {
var idss= $(el).attr('id');
alert(idss);
}
</script>
No comments:
Post a Comment