javascript - 如何替换html中的doctype?

标签 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 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>

在上面的代码中我使用了自定义的 css 复选框,但是在我的 jsp 中我不能使用标签

<!doctype html>

那么,除了<!doctype html>还有其他选择吗? ,因为上面的代码没有它就无法工作

最佳答案

您仍然可以从 JSP 声明 HTML5 文档类型:

<![CDATA[<!DOCTYPE html>]]>

关于javascript - 如何替换html中的doctype?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18485454/

相关文章:

javascript - jQuery Ajax 成功函数返回空值?

javascript - React select - 如何根据其他选择字段的选取选项来过滤选择?

javascript - Angular - 添加选项以使用 Jquery 进行选择

html - HDPI 和 MDPI 笔记本电脑屏幕的媒体查询不起作用

javascript - 如何在 Angular 1.5 子组件中触发操作?

javascript - 主干路由器监听器未命中哈希标签

jQuery 切换与 div 层次结构

php - 有效地维护项目符号点的顺序,例如mysql中的列表

javascript - 函数执行得太快

html - 基本 HTML - 应用 div id