我有一个bootstrap 3表单,我通过脚本应用tootip。toottip在输入框上工作正常,但在textarea上不工作。

<div class="control-group">
              <label class="control-label" for="firstname">Message Subject : </label>
            <div class="controls">
              <input type="text" class="form-control"
              placeholder="Subject" id="name" name="Subject" maxlength="70" minlength="10" required
              data-validation-required-message="Please enter subject" aria-describedby="sizing-addon3" data-toggle="tooltip" title="Input Message Subject between 10 to 80" />
              <p class="help-block"></p>
            </div>
          </div>


          <div class="control-group">
            <div class="controls">
                <label class="control-label" for="content" >Message Content : </label>
              <textarea rows="10" cols="100" class="form-control"
              placeholder="Message" id="message" name="Content" required
              data-validation-required-message="Please enter your message" minlength="5"
              data-validation-minlength-message="Min 5 characters"
              maxlength="999" style="resize:none" data-toggle="tooltip" title="Input Message Subject between 50 to 500"></textarea>
            </div>
          </div>

剧本是这样的
 $('a').tooltip({placement: "top"});

    $('input[type=text][name=Subject]').tooltip({
    placement: "right",
    trigger: "focus"
});

$('input[type=textarea][name=Content]').tooltip({
    placement: "right",
    trigger: "focus"
});

它可以很好地处理输入文本,但不能处理文本区域。。

最佳答案

您的选择器错误,请将其更改为:

$('textarea[name=Content]')

JsFiddle

08-19 14:09