简体   繁体   English

如何将跨度存储在php变量中,然后用作工具提示文本

[英]How to store span in php variable then used as it tooltip text

I tried to use tooltip for showing the value of span (which is span value to check user availability), so i store span value in php variable on echo it on tooltip tittle but not working. 我尝试使用工具提示显示span的值(这是用于检查用户可用性的span值),因此我将span值存储在php变量中,在工具提示标题上将其回显,但不起作用。

here's my code 这是我的代码

for example label nm_usr is the right tooltip and label log_usr is the variable i tried to echo it 例如,标签nm_usr是正确的工具提示,而标签log_usr是我尝试回显的变量

    <tr>
        <td><label for="nm_usr">Nama</label></td>
        <td><input name="nm_usr" type="text" class="required" minlength="6" id="nm_usr" data-toggle="tooltip" data-placement="right" tittle="Masukkan nama lengkap anda" /></td>
    </tr>
    <tr>
        <td><label for="log_usr">Username</label></td>
        <?php
            $tittle = "<span id="usercheck" style="padding-left:10px; ; vertical-align: middle;"></span>";
        ?>
        <td><input name="log_usr" type="text" class="required" minlength="6" id="log_usr" onblur="checkUserName(this.value)" data-toggle="tooltip" data-placement="right" tittle="<?php echo $tittle;?>" />
        </td>
    </tr>

(1) The attribute that you are looking for is title (not tittle). (1)您要查找的属性是标题(不是标题)。

(2) You should not put HTML inside the title attribute; (2)您不应将HTML放在title属性内; it is invalid markup/will not validate. 无效的标记/将无法验证。

(3) Your PHP code contains a syntax error: (3)您的PHP代码包含语法错误:

$tittle = "<span id="usercheck" style="padding-left:10px; vertical-align: middle;"></span>";

Should be replaced with: 应替换为:

$tittle = '<span id="usercheck" style="padding-left:10px; ; vertical-align: middle;"></span>';

If you do wish to have HTML inside tooltips, I would suggest checking out jQuery UI's tooltips feature: 如果您确实希望在工具提示中包含HTML,我建议您查看jQuery UI的工具提示功能:

https://jqueryui.com/tooltip/ https://jqueryui.com/tooltip/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM