$(function(){
var one = 'twitter';
var two = 'about';
var three = 'contact';
var four = 'exp';
var five = 'price';
$('#twitter').hover(function(){
$(this).append('<p class="hvtext" id="twitterz">'+ one + '</p>');
$('.hvtext').css({left:'1.7em',
bottom: '0.1em'});
}, function(){
$('.hvtext').hide();
});
$('#about').hover(function(){
$(this).append('<p class="hvtext">' + two + '</p>');
$('.hvtext').css({left:'1.7em', bottom:'0.1em'});
}, function(){
$('.hvtext').hide();
});
$('#contact').hover(function(){
$(this).append('<p class="hvtext">'+ three + '</p>')
$('.hvtext').css({left:'1.2em', bottom:'0.1em'});
}, function(){
$('.hvtext').hide();
});
$('#experience').hover(function(){
$(this).append('<p class="hvtext">'+ four + '</p>');
$('.hvtext').css({left:'2.3em', bottom:'0.1em'});
}, function(){
$('.hvtext').hide();
});
$('#prices').hover(function(){
$(this).append('<p class="hvtext">'+ five + '</p>');
$('.hvtext').css({left:'2em',bottom:'0.1em'});
}, function(){
$('.hvtext').hide();
});
one.click(function(){
alert('element exists');
});
});
I'm trying to find a way of calling the .hvtext class as a selector which will be later used as an on click event.
Problem is, the class is added dynamically by .append, i tried using .is(':visible') and couldn't find it?
Another problem: since it's a class I also want to identify them individually, should i just use Id's?
To solve this I tried to distinguish them by adding a var for each of the texts hoping I could call them later as an event, but since they're just variable strings and not an element I can't.
Is there anyway I can achieve this?
$('#' + one).on('click', function() {/* code */});