[ 2 posts ]

israr

  • Joined: Tue Apr 17, 2012 3:21 am
  • Posts: 1
  • Offline
  • Profile
Tags:

accesing the innerHTML of a click

Post Posted: Tue Apr 17, 2012 3:25 am
+0-
How can I access the innerHTML of div , when the div is clicked.
I try this but it returns undefined.

YUI().use('node', function(Y) {

var makeChoice=function(e) {

//var thisDiv=(evt)? evt.target:window.event.srcElement;
var target=e.target;
alert(target.innerHTML);
document.getElementById("searchField").value=target.innerHTML;
document.getElementById("popups").innerHTML="";
};
Y.one('.divSuggestions').on('click', makeChoice);

});

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile

Re: accesing the innerHTML of a click

Post Posted: Tue Apr 17, 2012 5:07 am
+0-
Code:
var makeChoice = function(e) {
    var target = e.target;
    console.log(target.get('innerHTML'));
};


http://yuilibrary.com/yui/docs/node/#node-properties
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum