Javascript 如何在html中替换doctype?
这是我的代码:Javascript 如何在html中替换doctype?,javascript,jquery,html,css,jsp,Javascript,Jquery,Html,Css,Jsp,这是我的代码: <!doctype html> <html> <head> <meta charset="utf-8"> <title>jQuery Checkbox and Radio Button Styling</title> <style type="text/css"> /* * customRadioCheck: jQuery plugin for checkbox and radio repl
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Checkbox and Radio Button Styling</title>
<style type="text/css">
/*
* customRadioCheck: jQuery plugin for checkbox and radio replacement
* Usage: $('input[type=checkbox], input[type=radio]').customRadioCheck();
* Author: Cedric Ruiz
* License: MIT
*/
.custom-label {
display: inline-block;
margin-right: .8em;
cursor: pointer;
}
.custom-radio,
.custom-check {
vertical-align: middle;
display: inline-block;
position: relative;
top: -.15em; /* Adjust to for best fit */
margin: 0 .4em;
width: 20px;
height: 20px;
background: url(img/customRadioCheck.png) 0 0 no-repeat;
}
.custom-radio { background-position: 0 -20px; }
.custom-check.focus { background-position: -20px 0; }
.custom-radio.focus { background-position: -20px -20px; }
.custom-check.checked { background-position: -40px 0; }
.custom-radio.checked { background-position: -40px -20px; }
.custom-check.checked.focus { background-position: -60px 0; }
.custom-radio.checked.focus { background-position: -60px -20px; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
/*
* customRadioCheck: jQuery plguin for checkbox and radio replacement
* Usage: $('input[type=checkbox], input[type=radio]').customRadioCheck();
* Author: Cedric Ruiz
* License: MIT
*/
;(function(){
$.fn.customRadioCheck = function() {
return this.each(function() {
var $this = $(this);
var $span = $('<span/>');
$span.addClass('custom-'+ ($this.is(':checkbox') ? 'check' : 'radio'));
$this.is(':checked') && $span.addClass('checked'); // init
$span.insertAfter($this);
$this.parent('label').addClass('custom-label')
.attr('onclick', ''); // Fix clicking label in iOS
// hide by shifting left
$this.css({ position: 'absolute', left: '-9999px' });
// Events
$this.on({
change: function() {
if ($this.is(':radio')) {
$this.parent().siblings('label')
.find('.custom-radio').removeClass('checked');
}
$span.toggleClass('checked', $this.is(':checked'));
},
focus: function() { $span.addClass('focus'); },
blur: function() { $span.removeClass('focus'); }
});
});
};
}());
</script>
</head>
<body>
<a href='http://1stwebmagazine.com/jquery-checkbox-and-radio-button-styling'><img src='../img/logo.png' alt='1stWebMagazine' /></a>
<h1>jQuery Checkbox and Radio Button Styling</h1>
<div>
<h3>Checkbox:</h3>
<label><input type="checkbox"/>sfdf</label><br/>
<label><input type="checkbox"/>Lamb</label><br/>
<label><input type="checkbox"/>Tiger</label><br/>
</div>
<div>
<h3>Radio button:</h3>
<label><input type="radio" name="n"/>Green</label><br/>
<label><input type="radio" name="n"/>Blue</label><br/>
<label><input type="radio" name="n"/>Orange</label><br/>
</div>
<script type="text/javascript">
$('input[type=checkbox], input[type=radio]').customRadioCheck();
</script>
</body>
</html>
jQuery复选框和单选按钮样式
/*
*customRadioCheck:用于复选框和无线电替换的jQuery插件
*用法:$('input[type=checkbox],input[type=radio]')。customRadioCheck();
*作者:塞德里克·鲁伊斯
*执照:麻省理工学院
*/
.定制标签{
显示:内联块;
右边距:.8em;
光标:指针;
}
.定制收音机,
.海关检查{
垂直对齐:中间对齐;
显示:内联块;
位置:相对位置;
顶部:-.15em;/*调整以获得最佳配合*/
边缘:0.4em;
宽度:20px;
高度:20px;
背景:url(img/customRadioCheck.png)0 0无重复;
}
.自定义收音机{背景位置:0-20px;}
.custom-check.focus{背景位置:-20px 0;}
.custom-radio.focus{背景位置:-20px-20px;}
.custom-check.checked{背景位置:-40px 0;}
.custom-radio.checked{背景位置:-40px-20px;}
.custom-check.checked.focus{背景位置:-60px 0;}
.custom-radio.checked.focus{背景位置:-60px-20px;}
/*
*customRadioCheck:jQuery plguin用于复选框和无线电替换
*用法:$('input[type=checkbox],input[type=radio]')。customRadioCheck();
*作者:塞德里克·鲁伊斯
*执照:麻省理工学院
*/
;(功能(){
$.fn.customRadioCheck=函数(){
返回此值。每个(函数(){
var$this=$(this);
变量$span=$('');
$span.addClass('custom-'+($this.is(':checkbox')?'check':'radio'));
$this.is(':checked')&&$span.addClass('checked');//init
$span.insertAfter($this);
$this.parent('label').addClass('custom-label'))
.attr('onclick','');//修复在iOS中单击标签的问题
//左移躲藏
$this.css({position:'absolute',left:'-9999px'});
//事件
$this.on({
更改:函数(){
如果($this.is(':radio')){
$this.parent()
.find('.custom radio').removeClass('checked');
}
$span.toggleClass('checked',$this.is(':checked');
},
focus:function(){$span.addClass('focus');},
blur:function(){$span.removeClass('focus');}
});
});
};
}());
jQuery复选框和单选按钮样式
复选框:
sfdf
羔羊肉
老虎
单选按钮:
绿色
蓝色
橙色
$('input[type=checkbox],input[type=radio]')。customRadioCheck();
在上面的代码中,我使用了定制的css复选框,但在我的jsp中,我不能使用标记
<!doctype html>
因此,除了
,还有其他选择吗,因为上面的代码没有它就无法工作我将创建3个页面,一个HTML、CSS和JSP,并将它们链接在一起。我将创建3个页面,一个HTML、CSS和JSP,并将它们链接在一起。您仍然可以从JSP声明HTML5 doctype:
<![CDATA[<!DOCTYPE html>]]>
]>
您仍然可以从JSP声明HTML5 doctype:
<![CDATA[<!DOCTYPE html>]]>
]>
试试这个
<!DOCTYPE html SYSTEM "about:legacy-compat">
有关详细信息:请尝试使用此选项
<!DOCTYPE html SYSTEM "about:legacy-compat">
有关详细信息:这里没有获得类似doctype的html对象的方法。你可以这样做
document.write("<!doctype HTML>\n" + document.head.outerHTML + document.body.outerHTML);
document.write(“\n”+document.head.outerHTML+document.body.outerHTML);
使用新的doctype并替换完整的html源代码。这里没有办法获得类似doctype的html对象。你可以这样做
document.write("<!doctype HTML>\n" + document.head.outerHTML + document.body.outerHTML);
document.write(“\n”+document.head.outerHTML+document.body.outerHTML);
使用新的doctype并替换完整的html源代码。在问题得到解决之前,最好看到您以评论和其他问题的形式参与。在问题得到解决之前,最好看到您以评论和其他问题的形式参与。