欧美国产另类久热|951超碰伊人久久|伊人影视久久久久|色婷婷亚洲小电影|色东京热69XX|婷婷玖玖深爱网|加勒比东京热网站|无码A级毛片在线观看|一级a毛一级a看|中文字幕人妻欧美

基于JS代碼實現(xiàn)當(dāng)鼠標(biāo)懸停表格上顯示這一格的全部內(nèi)容
來源:易賢網(wǎng) 閱讀:2452 次 日期:2016-06-20 12:04:32
溫馨提示:易賢網(wǎng)小編為您整理了“基于JS代碼實現(xiàn)當(dāng)鼠標(biāo)懸停表格上顯示這一格的全部內(nèi)容”,方便廣大網(wǎng)友查閱!

想實現(xiàn)這樣一個功能,就是在一個表格中,由于很多字過多,所以用文字溢出的方法處理了,但是這樣就無法看到表格中具體的內(nèi)容呢。想實現(xiàn)當(dāng)鼠標(biāo)移上去的時候可以顯示這一行被隱藏的內(nèi)容。當(dāng)然這個網(wǎng)上有很多插件,但是我沒有用,還是自己寫了一個。

css部分

<style>

#showbox {

width: 150px;

min-height: 50px;

font: 100 14px/1 "微軟雅黑";

border: 1px solid #3c8dbc;

display: none;

position: absolute;

top: 0;

left: 0;

background-color: #fff;

padding: 5px;

}

</style>

html部分

<table id="example1" role="grid">

<thead style="background-color: #E4E9F0;">

<tr role="row">

<th rowspan="2" style="text-align: center; width: 6%;" class="sorting_disabled " colspan="1"><font style="font-weight:bold;">序號</font></th>

<th rowspan="2" style="text-align: center; width: 10%;" class="sorting_disabled " colspan="1"><font style="font-weight:bold;">名稱</font></th>

<th rowspan="2" style="text-align: center; width: 10%;" class="sorting_disabled " colspan="1"><font style="font-weight:bold;">類別</font></th>

<th rowspan="2" style="text-align: center; width: 8%;" class="sorting_disabled" colspan="1"><font style="font-weight:bold;">單位</font></th>

<th rowspan="2" style="text-align: center; width: 26%;" class="sorting_disabled " colspan="1"><font style="font-weight:bold;">成果要求</font></th>

<th colspan="2" style="text-align: center; " rowspan="1"><font style="font-weight:bold;">進(jìn)展</font></th></tr>

<tr role="row">

<th style="text-align: center; width: 30%;" class="sorting_disabled" rowspan="1" colspan="1"><font style="font-weight:bold;">最新進(jìn)展</font></th>

<th style="text-align: center; width: 10%;" class="sorting_disabled " rowspan="1" colspan="1"><font style="font-weight:bold;">更新時間</font></th></tr>

</thead>

<tbody>

<tr role="row">

<td>1</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td></td>

</tr>

<tr role="row">

<td>2</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td></td>

</tr>

<tr role="row" class="odd">

<td>3</td>

<td>阿拉蕾</td>

<td>阿拉蕾</td>

<td>阿拉蕾,</td>

<td>阿拉蕾</td>

<td></td>

</tr>

</tbody>

</table>

<div id="showbox"></div>

js部分

$(function() {

function showBox(obj,box){

var timer = null;

$(obj).on("mouseover", function (e) {

clearTimeout(timer);

var clientX = e.clientX;

var clientY = e.clientY;

var txt = $(this).text();

timer = setTimeout(function () {

console.log(clientX, clientY);

$(box).css("left", clientX).css("top", clientY);

if (txt == "") {

$(box).hide();

} else {

$(box).show();

$(box).html(txt);

}

}, 1000);

});

$(obj).on("mouseout",function(){

clearTimeout(timer);

$(box).hide();

});

}

showBox("#example1 > tbody td","#showbox");

});

最后,其實bootstrap里面有個組建可以顯示里面的內(nèi)容,只是顯示的是title,一開始不會改沒用那個,后經(jīng)人點醒,可以直接給title賦值,就是給title賦值為表格里面的text就好。

以上所述是小編給大家介紹的基于JS代碼實現(xiàn)當(dāng)鼠標(biāo)懸停表格上顯示這一格的全部內(nèi)容,希望對大家有所幫助

更多信息請查看網(wǎng)絡(luò)編程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點

版權(quán)所有:易賢網(wǎng)