-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (42 loc) · 1.36 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
$(document).ready(function(){
$('p.para1').css('color', 'green');
$('p.para2').css({color:'red', background: '#c1c1'}) //object
$('p.para3').addClass('myClass')
$('p.para4').removeClass('myClass')
$('#btn1').click(function(){
$('p.para5').toggleClass('myClass')
})
$('#myDiv').text('Hello World');
$('#myDiv').html('<h3>Hello World</h3>');
//alert($('#myDiv').text());
$('ul').append('<li>Append List Item</li>'); //last
$('ul').prepend('<li>Prepend List Item</li>');//fist
$('.para1').appendTo('.para2');
$('.para1').prependTo('.para2');
$('ul').before('<h4>Hello</h4>');
$('ul').after('<h4>World</h4>');
//$('ul').empty();
//$('ul').detach();
$('a').attr('target', '_blank');
//alert($('a').attr('href'));
$('a').removeAttr('target');
$('p').wrap('<h1>');
$('p').wrapAll('<h1>');
$('#newItem').keyup(function(e){
var code = e.which;
if(code == 13){ //13 is enter
e.preventDefault();
$('ul').append('<li>'+e.target.value+'</li>');
}
});
//Array
var myArr = ['Brad', 'Kelley', 'Nate', 'Jose'];
$.each(myArr, function(i, val){
$('#users').append('<li>'+val+'</li>');
});
var newArr = $('ul#list li').toArray();
console.log(newArr);
$.each(newArr, function(i, val){
console.log(val.innerHTML);
});
});