0

请查看这些 html 代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta name="gmapkey" content="" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />

    <title></title>

    <link rel="stylesheet" href="jqtransformplugin/jqtransform.css" type="text/css" media="all" />
    <link rel="stylesheet" href="demo.css" type="text/css" media="all" />

    <script type="text/javascript" src="requiered/jquery.js" ></script>
    <script type="text/javascript" src="jqtransformplugin/jquery.jqtransform.js" ></script>
    <script language="javascript">
        $(document).ready(function () {
            $('#abc').jqTransform({imgPath:'jqtransformplugin/img/'});
              });
    </script>

</head>
<body>

    <form class="formTransform" action="post.php" method="POST">
        <div class="rowElem"><label>Input Text:</label><input type="text" name="inputtext"/></div>
        <div class="rowElem"><label>Input Password:</label><input type="password" /></div>
        <div class="rowElem"><label>Checkbox: </label><input type="checkbox" name="chbox" id=""></div>
        <div class="rowElem"><label>Radio :</label> 
            <input type="radio" id="" name="question" value="oui" checked ><label>oui</label>
            <input type="radio" id="" name="question" value="non" ><label>non</label></div>
        <div class="rowElem"><label>Textarea :</label> <textarea cols="40" rows="12" name="mytext"></textarea></div>

        <div class="rowElem">
            <label>Select :</label>
            <select name="select">
                <option value="">1&nbsp;</option>
                <option value="opt1">2&nbsp;</option>
            </select>
        </div>
        <div class="rowElem">
            <label>Select Redimentionné :</label>
            <select name="select2" >
                <option class ="abc" value="opt1">Big Option test line with more wordssss</option>
                <option value="opt2">Option 2</option>
                <option value="opt3">Option 3</option>
                <option value="opt4">Option 4</option>
                <option value="opt5">Option 5</option>
                <option value="opt6">Option 6</option>
                <option value="opt7">Option 7</option>
                <option value="opt8">Option 8</option>
            </select>
        </div>

        <div class="rowElem"><label>Submit button:</label><input id="abc" type="submit" value="Envoyer" /></div>
        <div class="rowElem"><label>Reset button:</label><input type="reset" value="Annuler" /></div>
        <div class="rowElem"><label>Input button:</label><input type="button" value="bouton" /></div>

    </form>

</body>
</html>

为什么

    $(document).ready(function () {
        $('#abc').jqTransform({imgPath:'jqtransformplugin/img/'});
          });

不工作!
但是这个

    $(document).ready(function () {
        $('.formTransform').jqTransform({imgPath:'jqtransformplugin/img/'});
          });

作品!

那个 jquery 选择器有什么问题?

提前致谢

4

1 回答 1

1

看插件的代码,你必须用一个不是你选择的表单来调用jqTransform。
顺便说一句,插件是:“放弃项目。说再见。” (jcamenisch 于 7 个月前创作)
插件代码:

$.fn.jqTransform = function (options) {
var opt = $.extend({}, defaultOptions, options);

/* each form */
return this.each(function () {
  var $form = $(this);
  if ($form.hasClass('jqtransformdone')) {
    return;
  }
  $form.addClass('jqtransformdone');

  $('input:submit, input:reset, input[type="button"]', this).jqTransInputButton();
于 2012-10-30T06:45:51.103 回答