jquery 给span赋值赋值html

页面导航:
→ 正文内容 jQuery对html元素取值与赋值
jQuery对html元素取值与赋值的方法
这篇文章主要介绍了jQuery对html元素取值与赋值的方法,有需要的朋友可以参考一下
Jquery给基本控件的取值、赋值 TEXTBOX: var str = $('#txt').val(); $('#txt').val("Set Lbl Value"); //文本框,文本区域: $("#text_id").attr("value",'');//清空内容 $("#text_id").attr("value",'test');// 填充内容
代码如下:var str = $('#txt').val();$('#txt').val("Set Lbl Value");
//文本框,文本区域:$("#text_id").attr("value",'');//清空内容$("#text_id").attr("value",'test');// 填充内容
代码如下:var str = $('#lbl').text();$('#lbl').text("Set Lbl Value");
&& var valradio = $("input[@type=radio][@checked]").val();&& var item = $('input[@name=items][@checked]').val();var checkboxval = $("#checkbox_id").attr("value");&& var selectval = $('#select_id').val();//多选框checkbox:$("#chk_id").attr("checked",'');//使其未勾选$("#chk_id").attr("checked",true);// 勾选if($("#chk_id").attr('checked')==true) //判断是否已经选中单选组radio: 代码如下: $("input[@type=radio]").attr("checked",'2'); //设置value=2的项目为当前选中项//下拉框select:$("#select_id").attr("value",'test');// 设置value=test的项目为当前选中项$("&option value='test'&test&/option&&option value='test2'&test2&/option&").appendTo("#select_id")//添加下拉框的 option$("#select_id").empty();//清空下拉框获取一组名为 (items)的radio被选中项的值var item = $('input[@name=items][@checked]').val();//若未被选中 则val() = undefined获 取select被选中项的文本var item = $("select[@name=items] option[@selected]").text();select下拉框的第二个元素为当前选中值$('#select_id')[0].selectedIndex = 1;radio单选组的第二个元素为当前选中值$('input[@name=items]').get(1).checked =//重置表单$("form").each(function(){&& .reset();});
您可能感兴趣的文章:
上一篇:下一篇:
最 近 更 新
热 点 排 行
12345678910您还未登陆,请登录后操作!
怎样用jquery 给div层的title属性赋值?
给div层的title属性赋值?
你可以这样操作:
&div id="untitle"&&/div&
$(document).ready(function(){
$("#untitle").attr("title","赋值");
希望能帮助你。
大家还关注你的位置: >
> 基于jquery的bootstrap在线文本编辑器插件Summernote
Summernote是一个基于的bootstrap超级简单WYSIWYG在线。Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox、Opera、Internet Explorer 9 +(IE8支持即将到来)。
世界上最好的WYSIWYG
自定义初化选项
支持快捷键
适用于各种后端程序言语
使用html5文档
&!DOCTYPE&html&
引入核心文件,Summernote需要几个JS库的支持,所以得先引入其它库
&!--&include&libries(jQuery,&bootstrap,&fontawesome)&--&
&script&src=&///jquery-1.9.1.min.js&&&/script&
&link&href=&///bootstrap/3.0.1/css/bootstrap.min.css&&
&script&src=&///bootstrap/3.0.1/js/bootstrap.min.js&&&/script&
&link&href=&///font-awesome/4.0.3/css/font-awesome.min.css&&
&!--&include&summernote&css/js--&
&link&href=&summernote.css&&/&
&script&src=&summernote.min.js&&&/script&
写入html,只需加入一个DIV元素,写上ID
&div&id=&summernote&&Hello&Summernote&/div&
写入JS初始化插件
$(document).ready(function()&{
&&&&&&&&$('#summernote').summernote();
初始化Summernote
$('.summernote').summernote();
使用参数初始化
设定高度与焦点
$('.summernote').summernote({
&&height:&300,&&&&&&&&&&&&&&&&&//&set&editor&height
&&minHeight:&null,&&&&&&&&&&&&&//&set&minimum&height&of&editor
&&maxHeight:&null,&&&&&&&&&&&&&//&set&maximum&height&of&editor
&&focus:&true,&&&&&&&&&&&&&&&&&//&set&focus&to&editable&area&after&initializing&summernote});
设定高度后,如果内容高度超过设定高度将出现滚动条,如果没有设定高度则一直往下挣开。设定focus为true时,打开页面后焦点定位到编辑器中。
自定义工具栏
$('.summernote').summernote({
&&toolbar:&[
&&&&//[groupname,&[button&list]]
&&&&['style',&['bold',&'italic',&'underline',&'clear']],
&&&&['font',&['strikethrough']],
&&&&['fontsize',&['fontsize']],
&&&&['color',&['color']],
&&&&['para',&['ul',&'ol',&'paragraph']],
&&&&['height',&['height']],
Insert a picture
Insert a hyperlink
Insert a video
Insert a table
Insert a horizontal rule
Format selected block
Set font family
Set font size
Set foreground and background color
Toggle weight
Toggle italic
Toggle underline
strikethrough
Toggle strikethrough
Clearing all styles
Make an un-ordered list
Make an ordered list
Set text alignment
Set height of text
fullscreen
Toggle fullscreen editing mode
Toggle wysiwyg and html editing mode
Show help dialog
极简模式Air-mode
$('.summernote').summernote({
&&airPopover:&[
&&&&['color',&['color']],
&&&&['font',&['bold',&'underline',&'clear']],
&&&&['para',&['ul',&'paragraph']],
&&&&['table',&['table']],
&&&&['insert',&['link',&'picture']]
释放Summernote
$('.summernote').destroy();
取值与赋值
var&sHTML&=&$('.summernote').code();
//同一页面多个summernote时,取第二个的值
var&sHTML&=&$('.summernote').eq(1).code();
$('.summernote').code(sHTML);
$('#summernote').summernote({
&&oninit:&function()&{
&&&&console.log('Summernote&is&launched');
$('#summernote').summernote({
&&onenter:&function(e)&{
&&&&console.log('Enter/Return&key&pressed');
$('#summernote').summernote({
&&onfocus:&function(e)&{
&&&&console.log('Editable&area&is&focused');
$('#summernote').summernote({
&&onblur:&function(e)&{
&&&&console.log('Editable&area&loses&focus');
$('#summernote').summernote({
&&onkeyup:&function(e)&{
&&&&console.log('Key&is&released:',&e.keyCode);
$('#summernote').summernote({
&&onkeydown:&function(e)&{
&&&&console.log('Key&is&pressed:',&e.keyCode);
$('#summernote').summernote({
&&onpaste:&function(e)&{
&&&&console.log('Called&event&paste');
onImageUpload
可以重写图片上传句柄
$('#summernote').summernote({
&&onImageUpload:&function(files,&editor,&$editable)&{
&&&&console.log('image&upload:',&files,&editor,&$editable);
IE9-10: DOMCharacterDataModified, DOMSubtreeModified, DOMNodeInserted
Chrome, FF: input
$('#summernote').summernote({
&&onChange:&function(contents,&$editable)&{
&&&&console.log('onChange:',&contents,&$editable);
支持18国语言,使用时引入你需要的语言文件,lang值设为你需要的语言
&!--&include&summernote-ko-KR&--&
&script&src=&lang/summernote-ko-KR.js&&&/script&
$(document).ready(function()&{
&&$('#summernote').summernote({
&&&&lang:&'ko-KR'&//&default:&'en-US'
更多参数请查看实例与
转载请注明: &
下载地址: |
与本文相关的文章ASP.NET &&&&最新内容
ASP.NET &&&&随机内容1134人阅读
摘要:&Jquery给基本控件的取值、赋值 TEXTBOX: var str = $('#txt').val(); $('#txt').val(&Set Lbl Value&); //文本框,文本区域:
$(&#text_id&).attr(&value&,'');//清空内容 $(&#text_id&).attr(&value&,'test');// 填充内容
Jquery给基本控件的取值、赋值
var str = $('#txt').val();
&$('#txt').val(&Set Lbl Value&);&
//文本框,文本区域:
$(&#text_id&).attr(&value&,'');//清空内容
$(&#text_id&).attr(&value&,'test');// 填充内容
var str = $('#lbl').text();
$('#lbl').text(&Set Lbl Value&);
&& var valradio = $(&input[@type=radio][@checked]&).val();
&& var item = $('input[@name=items][@checked]').val();
var checkboxval = $(&#checkbox_id&).attr(&value&);
&& var selectval = $('#select_id').val();
//多选框checkbox:
$(&#chk_id&).attr(&checked&,'');//使其未勾选
$(&#chk_id&).attr(&checked&,true);// 勾选
if($(&#chk_id&).attr('checked')==true) //判断是否已经选中
单选组radio:
$(&input[@type=radio]&).attr(&checked&,'2'); //设置value=2的项目为当前选中项
//下拉框select:
$(&#select_id&).attr(&value&,'test');// 设置value=test的项目为当前选中项
$(&&option value='test'&test&/option&&option value='test2'&test2&/option&&).appendTo(&#select_id&)//添加下拉框的 option
$(&#select_id&).empty();//清空下拉框
获取一组名为 (items)的radio被选中项的值
var item = $('input[@name=items][@checked]').val();//若未被选中 则val() = undefined
获 取select被选中项的文本
var item = $(&select[@name=items] option[@selected]&).text();
select下拉框的第二个元素为当前选中值
$('#select_id')[0].selectedIndex = 1;
radio单选组的第二个元素为当前选中值
$('input[@name=items]').get(1).checked =
//重置表单
$(&form&).each(function(){
&& .reset();
摘要:&Jquery给基本控件的取值、赋值 TEXTBOX: var str = $('#txt').val(); $('#txt').val(&Set Lbl Value&); //文本框,文本区域:
$(&#text_id&).attr(&value&,'');//清空内容 $(&#text_id&).attr(&value&,'test');// 填充内容
Jquery给基本控件的取值、赋值
var str = $('#txt').val();
&$('#txt').val(&Set Lbl Value&);&
//文本框,文本区域:
$(&#text_id&).attr(&value&,'');//清空内容
$(&#text_id&).attr(&value&,'test');// 填充内容
var str = $('#lbl').text();
$('#lbl').text(&Set Lbl Value&);
&& var valradio = $(&input[@type=radio][@checked]&).val();
&& var item = $('input[@name=items][@checked]').val();
var checkboxval = $(&#checkbox_id&).attr(&value&);
&& var selectval = $('#select_id').val();
//多选框checkbox:
$(&#chk_id&).attr(&checked&,'');//使其未勾选
$(&#chk_id&).attr(&checked&,true);// 勾选
if($(&#chk_id&).attr('checked')==true) //判断是否已经选中
单选组radio:
$(&input[@type=radio]&).attr(&checked&,'2'); //设置value=2的项目为当前选中项
//下拉框select:
$(&#select_id&).attr(&value&,'test');// 设置value=test的项目为当前选中项
$(&&option value='test'&test&/option&&option value='test2'&test2&/option&&).appendTo(&#select_id&)//添加下拉框的 option
$(&#select_id&).empty();//清空下拉框
获取一组名为 (items)的radio被选中项的值
var item = $('input[@name=items][@checked]').val();//若未被选中 则val() = undefined
获 取select被选中项的文本
var item = $(&select[@name=items] option[@selected]&).text();
select下拉框的第二个元素为当前选中值
$('#select_id')[0].selectedIndex = 1;
radio单选组的第二个元素为当前选中值
$('input[@name=items]').get(1).checked =
//重置表单
$(&form&).each(function(){
&& .reset();
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:952617次
积分:12643
积分:12643
排名:第445名
原创:336篇
转载:234篇
评论:157条
阅读:9937
阅读:5093
(1)(3)(4)(1)(2)(2)(3)(2)(2)(3)(6)(2)(7)(4)(6)(2)(1)(4)(3)(1)(13)(8)(2)(6)(5)(20)(9)(3)(2)(16)(27)(6)(23)(11)(12)(16)(14)(45)(39)(42)(16)(24)(1)(2)(3)(2)(9)(21)(10)(24)(69)(11)

我要回帖

更多关于 jquery 赋值 的文章

 

随机推荐