如何使用从标题动态文本 [英] how to use text from title dynamic
问题描述
即时通讯使用以下工具提示code,我在SO发现,目前该文本在标题部分硬codeD,问题是我需要在不同的标签具有不同的文字标题使用而不是硬coded到所有的标签,我应该怎么改变它支持不同的标题文本的标签。
< DIV CLASS =表单组>
@ Html.LabelFor(型号=> model.Name,新{@class =控制标签COL-MD-2})
< DIV CLASS =COL-MD-10>
@ Html.EditorFor(型号=> model.Name)
<跨度类=标签标签主要mytooltip>< / SPAN>
@ Html.ValidationMessageFor(型号=> model.Name)
< / DIV> < / DIV>
这是脚本
$(文件)。就绪(
功能(){ $(。mytooltip)。提示({
动画:真,
位置:右,
标题:工具提示文本......,
触发:悬停
});
我已经为你的jsfiddle ...
code: -
$(文件)。就绪(
功能(){ $([标题])。提示({
动画:真,
位置:右, 触发:悬停
});
});
悬停在文本框,看到提示是working.you需要添加属性的标题以在其上要显示的工具提示标签。
工作的例子: - http://jsfiddle.net/dwxmjkb3/10/
我已经更新了你的jsfiddle,现在如果用户将鼠标悬停在标签,输入或?然后它会显示tooltip.i刚刚添加标题主分区。
看到的例子: - http://jsfiddle.net/dwxmjkb3/11/
感谢
Im using the following tool-tip code which I found in SO and currently the text is hard-coded in the title section, the problem is I need to use it in different label with different text title and not hard-coded to all the labels ,how should I change it to support any label with different title text.
<div class="form-group">
@Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name)
<span class="label label-primary mytooltip">?</span>
@Html.ValidationMessageFor(model => model.Name)
</div>
</div>
This is the script
$(document).ready(
function () {
$(".mytooltip").tooltip({
animation: "true",
placement: "right",
title: "Tooltip texts....",
trigger: "hover"
});
i have created a jsfiddle for you...
code:-
$(document).ready(
function () {
$("[title]").tooltip({
animation: "true",
placement: "right",
trigger: "hover"
});
});
hover on textbox and see the tooltip is working.you need to add a attribute title to the labels on which you want to show the tool tip.
working example:-http://jsfiddle.net/dwxmjkb3/10/
i have updated the jsfiddle for you, now if user will hover the label, input or ? then it will show the tooltip.i just added the title to the main div.
see the working example:-http://jsfiddle.net/dwxmjkb3/11/
thanks
这篇关于如何使用从标题动态文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!