简体   繁体   中英

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.

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

    <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).

(2) You should not put HTML inside the title attribute; it is invalid markup/will not validate.

(3) Your PHP code contains a syntax error:

$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:

https://jqueryui.com/tooltip/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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