-1
我有兩個問題我怎樣才能在ATTR標題顯示代碼的HTML
1-隱藏默認標題ATTR
2-顯示在ATTR標題(未標記但結果)的代碼的HTML
個我不能使用任何插件
只的CSS和jQuery(未jQuery的UI)被允許使用
感謝您的幫助
/* Jquery */
$(document).ready(function(){
var content = ' \
<div class="title-inner"> \
<h2>Lorem ipsum</h2> \
<img src="https://placehold.it/200x200"> \
<p>Quisque efficitur </p> \
</div>';
$('#link').attr('title', content);
})
/*CSS*/
.box{
background-color: #f2f2f2;
width: 50%;
padding: 20px;
}
.box a{
color: #fff;
text-decoration: none;
display: inline-block;
background-color: #ff6600;
padding: 10px 30px;
border: 1px solid #ff6600;
}
.box a:hover{
color: #ff6600;
background-color: transparent;
}
.box a[title]:hover:after {
content: attr(title);
padding: 4px 8px;
color: #333;
position: absolute;
margin-right: -20px;
margin-top: 10px;
z-index: 20;
white-space: nowrap;
border-radius: 5px;
box-shadow: 0px 0px 4px rgba(0,0,0,0.5);
background-color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Code HTML -->
<div class="box">
<a href="#" id="link" title="the title">Link</a>
</div>
<!-- this is the code to display in title attr-->
<!--
<div class="title-inner">
<h2>Lorem ipsum</h2>
<img src="https://placehold.it/200x200/ffff00/000000/?text=image-1" alt="image">
<p>Quisque efficitur arcu a sollicitudin consectetur. Etiam sit amet dui id sem porttitor faucibus non vitae sem. Donec tortor metus, tincidunt vitae viverra eu, pharetra mattis ipsum</p>
</div>
-->
您可以使用引導提示http://getbootstrap.com/javascript/#tooltips –
第一,我不能使用自舉。第二個更多的信息,你怎麼能把html的工具提示bootstrap? – bfahmi