$('h1').on('click', function(){
$(this).html(function(index, html){
return html + '+';
});
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
.reverse{
background: black;
color:white;
}
</style>
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script type="text/javascript">
$(function(){
$('h1').hover(function(){
$(this).addClass('reverse');
}, function(){
$(this).removeClass('reverse');
});
});
</script>
</head>
<body>
<h1>1</h1>
<h1>2</h1>
<h1>3</h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
.reverse{
background: black;
color:white;
}
</style>
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script type="text/javascript">
$(function(){
$('h1').click(function(){
$(this).html('CLICK');
alert('이벤트가 발생');
//이벤트 제거
$(this).off();
});
$('h1').off();
});
</script>
</head>
<body>
<h1>1</h1>
<h1>2</h1>
<h1>3</h1>
</body>
</html>
var header = $('h1', this).text();
var paragraph = $('p', this).text();
$(function(){
$('h1').click(function(){
$(this).html(function(index, html){
return '@'+html;
});
// 1초마다 함수실행
setInterval(function(){
$('h1').first().trigger('click');
}, 1000);
});
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
*{
margin: 5px;
padding: 5px;
border: 3px solid black;
}
</style>
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script type="text/javascript">
$(function(){
$('a').click(function(){
$(this).css('background-color','blue');
event.preventDefault();
event.stopPropagation();
});
$('h1').click(function(){
$(this).css('background-color', 'red');
});
});
</script>
</head>
<body>
<h1>
<a href = "html://hanbit.co.kr">Hanbit</a>
</h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
</style>
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script type="text/javascript">
$(function(){
$('h1').on('click', function(){
var length = $('h1').length;
var targetHTML = $(this).html();
$('#wrap').append('<h1>'+length+'-'+targetHTML+'</h1>');
});
});
</script>
</head>
<body>
<div id='wrap'>
<h1>Header</h1>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
</style>
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script type="text/javascript">
$(window).scroll(function(){
var scrollHeight = $(window).scrollTop() + $(window).height();
var documentHeight = $(document).height();
if(scrollHeight == documentHeight){
for(var i = 0; i < 10; ++i){
$('<h1>Infinity Scroll</h>').appendTo('body');
}
}
});
$(function(){
for(var i = 0; i <20 ;++i)
$('<h1>Infinity Scroll</h1>').appendTo('body');
});
</script>
</head>
<body>
</body>
</html>