$('#message').css('background', 'yellow').html('Hello!').show();
来源:互联网 发布:mac python 编辑:程序博客网 时间:2024/05/29 16:48
<html>
<head>
<title>标题</title>
<script type="text/javascript" src="jQuery\jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(function(){
$('#external_links a').click(
function()
{
return confirm('You are going to visit: ' + this.href);
}
);
});
</script>
</head>
<body>
<div id="external_links">
<a href="http://www.baidu.com">baidu</a><br>
<a href="www.google.com">google</a><br>
</div>
<hr>
<script type="text/javascript">
$('<p></p>') .html('Hey World!') .css('background', 'yellow') .appendTo("body");
</script>
<hr>
</body>
</html>
第四种方法可以使用字符串来创建元素。结果会产生一个包含该元素的 jQuery 对象。清单 3 显示的示例在页面中添加了一个段落。 清单 3. 创建和附加一个简单的段落 $('<p></p>') .html('Hey World!') .css('background', 'yellow') .appendTo("body");
在前一个例子中您可能已经注意到,jQuery 中的另一个功能强大的特性就是方法链接(method chaining)。
每次对 jQuery 对象调用方法时,方法都会返回相同的 jQuery 对象。这意味着如果您需要对 jQuery 对象调用多个方法,那么您不必重新键入选择器就可以实现这一目的: $('#message').css('background', 'yellow').html('Hello!').show();
<html>
<head>
<title>标题</title>
<script type="text/javascript" src="jQuery\jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(function(){
$('#external_links a').click(
function()
{
return confirm('You are going to visit: ' + this.href);
}
);
});
</script>
</head>
<body>
<div id="external_links">
<a href="http://www.baidu.com">baidu</a><br>
<a href="www.google.com">google</a><br>
</div>
<div id="message" >
</div>
<hr>
<script type="text/javascript">
$('<p></p>') .html('Hey World!') .css('background', 'yellow') .appendTo("body");
$('#message').css('background', 'green').html('Hello!').show();
</script>
<hr>
</body>
</html>
- $('#message').css('background', 'yellow').html('Hello!').show();
- html+css----background
- HTML/CSS: background-clip 与 background-origin的区别
- 搞定HTML\CSS之background属性
- HTML&CSS——CSS3 Background-size
- HTML CSS 盒模型 +background 使用
- Yellow
- HTML&CSS——利用CSS定位背景图片 background-position
- css background
- CSS Background
- CSS Background
- css background
- CSS-background
- css background
- C# Message.Show
- HTML+CSS Hello World及标签认识
- HTML+CSS Hello World及标签认识
- [CSS]CSS background属性
- JSP6个常用标签
- 嵌入式学习笔记: Cortex-A8 外部中断
- 用markdown写博客
- Spark任务提交与执行之RDD的创建、转换及DAG构建
- javascript 数组随机排序
- $('#message').css('background', 'yellow').html('Hello!').show();
- tinyxml2使用方法
- LeetCode : Pascal's Triangle
- 矩形的面积
- WFI
- 点名
- html5移动端适配使用流体布局经常遇到的坑
- 实验二.任务三.TASK
- 回文检测(包含中文与字符)