Hi there,
I am trying to get some information of a child element of an li
using mootools, essentially my html looks like this,
<li><a href="/home" id="home" class="nav-link">Home</a></li>
I am wanting to be able get the id, class and href of the a tag using mootools, so far my javascript looks similar to this,
$$('.rate').each(function(element,i){
element.addEvent('click', function(){
var myStyles = ['nostar', 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar', 'sixstar', 'sevenstar', 'eightstar', 'ninestar', 'tenstar'];
myStyles.each(function(myStyle){
if(element.getParent().hasClass(myStyle)){
element.getParent().removeClass(myStyle)
}
});
myStyles.each(function(myStyle, index){
if(index == element.id){
element.getParent().toggleClass(myStyle);
var req = new Request({
method:'post',
url: '/recipes/save',
data: {'rating' : element.id},
onRequest: function(){ alert('Request made. Please wait...');},
onComplete:function(response){ alert('Response:' + response);}
}).send();
alert('Clicked '+element.id);
alert(element.getChildren().get('href');
}
});
});
});
The final alert in the script is my attempt to the child of the li(element) and its href.