<!DOCTYPE html>
    <html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
    <head>
<title>Cách dùng HTML với tooltip Twitter Bootstrap bằng jQuery</title>
<meta name="description" content="Cách dùng HTML với tooltip Twitter Bootstrap bằng jQuery - Savefile - Tin Tức -...">
<meta name="author" content=".: Nguoicodonvn2008.info - Cõi lòng người cô đơn :.">
<meta name="copyright" content=".: Nguoicodonvn2008.info - Cõi lòng người cô đơn :. [admin@nguoicodonvn2008.info]">
<meta name="robots" content="index, archive, follow, noodp">
<meta name="googlebot" content="index,archive,follow,noodp">
<meta name="msnbot" content="all,index,follow">
<meta name="generator" content="NukeViet v4.5">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="Cách dùng HTML với tooltip Twitter Bootstrap bằng jQuery">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Tin Tức - https&#x3A;&#x002F;&#x002F;www.nguoicodonvn2008.info&#x002F;vi&#x002F;news&#x002F;savefile&#x002F;kien-thuc-may-tinh&#x002F;cach-dung-html-voi-tooltip-twitter-bootstrap-bang-jquery-6689.html">
<meta property="og:site_name" content=".&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.">
<meta property="og:url" content="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/cach-dung-html-voi-tooltip-twitter-bootstrap-bang-jquery-6689.html">
<link rel="shortcut icon" href="https://www.nguoicodonvn2008.info/favicon.ico">
<link rel="canonical" href="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/cach-dung-html-voi-tooltip-twitter-bootstrap-bang-jquery-6689.html">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/" title="Tin Tức" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/karaoke-dual/" title="Tin Tức - Karaoke Dual" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/nhac-tre/" title="Tin Tức - Nhạc trẻ" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tru-tinh/" title="Tin Tức - Trữ tình" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/nuoc-ngoai/" title="Tin Tức - Nước ngoài" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/remix/" title="Tin Tức - Remix" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tam-su-tinh-yeu/" title="Tin Tức - Tâm sự tình yêu" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tho-suu-tam/" title="Tin Tức - Thơ sưu tầm" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/cuoc-song/" title="Tin Tức - Cuộc sống" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/phan-mem/" title="Tin Tức - Phần mềm" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/kien-thuc-may-tinh/" title="Tin Tức - Kiến thức máy tính" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/hoc-tap/" title="Tin Tức - Học tập" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/tai-lieu/" title="Tin Tức - Tài liệu" type="application/rss+xml">
<link rel="alternate" href="https://www.nguoicodonvn2008.info/vi/news/rss/de-thi/" title="Tin Tức - Đề thi" type="application/rss+xml">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/style.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/news.css" type="text/css">
<link rel="preload" as="style" href="https://www.nguoicodonvn2008.info/themes/default/css/custom.css" type="text/css">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.nguoicodonvn2008.info/themes/default/js/bootstrap.min.js" type="text/javascript">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/style.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/style.non-responsive.css">
<link rel="StyleSheet" href="https://www.nguoicodonvn2008.info/themes/default/css/news.css">
<link rel="stylesheet" href="https://www.nguoicodonvn2008.info/themes/default/css/custom.css">
<style type="text/css">
	body{background: #fff;}
</style>
    </head>
    <body>
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">.&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.</h2>
		<p class="pull-right"><a title=".&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;." href="https://www.nguoicodonvn2008.info/">https://www.nguoicodonvn2008.info</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Cách dùng HTML với tooltip Twitter Bootstrap bằng jQuery</h1>
		<ul class="list-inline">
			<li>Thứ ba - 07/02/2023 23:19</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
		</div>
				<div class="imghome">
			<img alt="Cách dùng HTML với tooltip Twitter Bootstrap bằng jQuery" src="https://st.quantrimang.com/photos/image/2023/02/08/Bootstrap-tooltip-demo.jpg" width="460" class="img-thumbnail" />
		</div>
		<div class="clear"></div>
		<div id="bodytext" class="clearfix">
			<p style="text-align: justify;"><strong>Bootstrap Tooltip</strong>&nbsp;cho người dùng gợi ý về phần tử cụ thể theo cách trực quan nhất. Tooltip thường được dùng nhằm tăng hiệu suất bởi bạn có thể tùy biến nó theo domain yêu cầu.</p>

<p style="text-align: justify;">Tooltip được triển khia bằng cách dùng JavaScript. Nó dựa vào thư viện bên thứ ba, được gọi là popper.js, phục vụ cho việc xác định vị trí.</p>

<p style="text-align: justify;">Nó hoạt động dựa trên khái niệm “hover-over” bằng cách sử dụng con trỏ chuột khi di chuyển trên phần tử, một gợi ý sẽ xuất hiện theo 4 hướng bất kỳ (trái, phải, lên và xuống) theo chỉ dẫn trong code.</p>

<p style="text-align: justify;">Hãy xem xét ví dụ dưới đây để thấy rõ điều đó.</p>

<ul>
	<li style="text-align: justify;">Trong<strong>&nbsp;SignIn Page</strong>, tooltip Password hiện các yêu cầu như nó phải dài 8 ký tự, bắt đầu bằng chữ viết hoa…</li>
	<li style="text-align: justify;">Đối với&nbsp;<strong>name</strong>, nó có thể hiện ra chỉ tên đầu tiên, không có tên đệm hoặc họ.</li>
</ul>

<p style="text-align: justify;">Đoạn code JavaScript:</p>

<pre id="pre0" style="text-align: justify;">
// Viết code Javascript ở đây
$(function () {
  $(&#039;&#91;data-toggle=&quot;tooltip&quot;&#93;&#039;).tooltip()
})</pre>

<p style="text-align: justify;"><strong>Lưu ý</strong>: HTML, CSS, Bootstrap, JavaScript và jQuery được sử dụng.</p>

<p style="text-align: justify;"><strong>Cách 1:</strong>&nbsp;Triển khai code bên dưới được thực hiện cho 4 nút bên trái, phải, lên và xuống. Các tooltip tương ứng cho biết vị trí của các nút bấm tương ứng khi con trỏ trỏ qua nút bấm đó.</p>

<pre id="pre1" style="text-align: justify;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
	&lt;meta name=&quot;viewport&quot; content=
		&quot;width=device-width,initial-scale=1.0&quot; /&gt;
	&lt;title&gt;
		HTML với twitter Bootstrap
		tooltip bằng jQuery
	&lt;/title&gt;

	&lt;link rel=&quot;stylesheet&quot; href=
&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css&quot;
		integrity=
&quot;sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7&quot;
		crossorigin=&quot;anonymous&quot;&gt;
	&lt;script src=
&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js&quot;&gt;
	&lt;/script&gt;
	&lt;script src=
&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js&quot;
			integrity=
&quot;sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS&quot;
			crossorigin=&quot;anonymous&quot;&gt;
	&lt;/script&gt;

	&lt;script type=&quot;text/javascript&quot;&gt;
		$(document).ready(function() {
			$(&quot;#toptip&quot;).tooltip({
				placement: &quot;top&quot;
			});

			$(&quot;#bottomtip&quot;).tooltip({
				placement: &quot;bottom&quot;
			});

			$(&quot;#lefttip&quot;).tooltip({
				placement: &quot;left&quot;
			});

			$(&quot;#righttip&quot;).tooltip({
				placement: &quot;right&quot;
			});
		});
	&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;center&gt;
	&lt;div class=&quot;container&quot;&gt;
		&lt;h1&gt;&lt;u&gt;Mẫu Bootstrap Tooltip cho Quantrimang.com&lt;/u&gt;&lt;/h1&gt;
	&lt;br/&gt;&lt;br/&gt;
	&lt;div&gt;
		&lt;button type=&quot;button&quot; id=&quot;toptip&quot;
				class=&quot;btn btn-danger&quot;
				title=&quot;A Tooltip with Top placement&quot;&gt;
			Tooltip trên
		&lt;/button&gt;
		&lt;br&gt;&lt;br&gt;
		&lt;button type=&quot;button&quot; id=&quot;bottomtip&quot;
				class=&quot;btn btn-info&quot;
				title=&quot;A Tooltip with Bottom placement&quot;&gt;
			Tooltip dưới
		&lt;/button&gt;
		&lt;br&gt;&lt;br&gt;
		&lt;button type=&quot;button&quot; id=&quot;lefttip&quot;
				class=&quot;btn btn-success&quot;
				title=&quot;A Tooltip with Left placement&quot;&gt;
			Tooltip bên trái
		&lt;/button&gt;
		&lt;br&gt;&lt;br&gt;
		&lt;button type=&quot;button&quot; id=&quot;righttip&quot;
				class=&quot;btn btn-warning&quot;
				title=&quot;A Tooltip with Right placement&quot;&gt;
			Tooltip bên phải
		&lt;/button&gt;
	&lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;
</pre>

<p style="text-align: justify;"><strong>Kết quả:</strong></p>

<p style="text-align: justify;"><img alt="Mẫu Bootstrap tooltip" data-i="0" data-src="https://st.quantrimang.com/photos/image/2023/02/08/Bootstrap-tooltip-demo.jpg" data-was-processed="true" height="375" src="https://st.quantrimang.com/photos/image/2023/02/08/Bootstrap-tooltip-demo.jpg" width="495" /></p>

<p style="text-align: justify;"><strong>Cách 2:&nbsp;</strong>Dưới đây là một mẫu code về trang Sign-up (đăng ký) với tooltip cung cấp mẹo/đề xuất. Tag form trong HTML được dùng để tạo một biểu mẫu và thêm các thuộc tính tooltip tương ứng.</p>

<pre id="pre2" style="text-align: justify;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
	&lt;title&gt;Bootstrap Grid&lt;/title&gt;
	&lt;!-- Latest compiled and minified CSS --&gt;
	&lt;link rel=&quot;stylesheet&quot;
		href=
&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css&quot;&gt;

	&lt;!-- Optional theme --&gt;
	&lt;link rel=&quot;stylesheet&quot;
		href=
&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css&quot;&gt;
	&lt;script src=
&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js&quot;&gt;
	&lt;/script&gt;

	&lt;!-- Latest compiled and minified JavaScript --&gt;
	&lt;script src=
&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js&quot;&gt;
	&lt;/script&gt;

	&lt;script type=&quot;text/javascript&quot;&gt;
		$(document).ready(function() {
			$(&#039;#name&#039;).tooltip({
				&#039;trigger&#039;: &#039;focus&#039;,
				&#039;title&#039;: &#039;Name is Required&#039;
			});

			$(&#039;#email&#039;).tooltip({
				&#039;trigger&#039;: &#039;focus&#039;,
				&#039;title&#039;: &#039;Email is Required&#039;
			});

			$(&#039;#password&#039;).tooltip({
				&#039;trigger&#039;: &#039;focus&#039;,
				&#039;title&#039;: &quot;Password is Required&quot;
			});
		});
	&lt;/script&gt;
	&lt;style&gt;
		.serif {
			font-family: &quot;Times New Roman&quot;, Times, serif;
		}
		p {
			padding: 20px;
		}
	&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;h1&gt;&lt;p class=&quot;serif&quot;&gt;Mẫu trang đăng ký trên Quantrimang.com&lt;/p&gt;&lt;/h1&gt;

	&lt;div class=&quot;container&quot; style=&quot;padding:50px;&quot;&gt;

		&lt;form role=&quot;form&quot;&gt;
			&lt;div class=&quot;form-group&quot;&gt;
				&lt;label for=&quot;firstname&quot;&gt;Tên&lt;/label&gt;
				&lt;input type=&quot;text&quot;
					name=&quot;Name&quot;
					class=&quot;form-control&quot;
					id=&quot;name&quot;
					placeholder=&quot;Enter Name&quot;&gt;
			&lt;/div&gt;
			&lt;div class=&quot;form-group&quot;&gt;
				&lt;label for=&quot;email&quot;&gt;Email&lt;/label&gt;
				&lt;input type=&quot;text&quot;
					name=&quot;email&quot;
					class=&quot;form-control&quot;
					id=&quot;email&quot;
					placeholder=&quot;Enter email&quot;&gt;
			&lt;/div&gt;

			&lt;div class=&quot;form-group&quot;&gt;
				&lt;label for=&quot;Password&quot;&gt;Mật khẩu&lt;/label&gt;
				&lt;input type=&quot;password&quot;
					name=&quot;password&quot;
					class=&quot;form-control&quot;
					id=&quot;password&quot;
					placeholder=&quot;Enter Password&quot;&gt;
			&lt;/div&gt;
		&lt;/form&gt;
	&lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;</pre>

<div style="text-align: justify;">&nbsp;</div>
		</div>
				<div id="author">
						<p>
				<strong>Nguồn tin:</strong>
				Quantrimang.com
			</p>
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/cach-dung-html-voi-tooltip-twitter-bootstrap-bang-jquery-6689.html" title="Cách dùng HTML với tooltip Twitter Bootstrap bằng jQuery">https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/cach-dung-html-voi-tooltip-twitter-bootstrap-bang-jquery-6689.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; .&#x3A; Nguoicodonvn2008.info - Cõi lòng người cô đơn &#x3A;.
		</div>
		<div id="contact">
			<a href="mailto:admin@nguoicodonvn2008.info">admin@nguoicodonvn2008.info</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://www.nguoicodonvn2008.info/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
		</script>
		<div class="car-top">
  <span><img src="https://www.nguoicodonvn2008.info/themes/default/images/car.png" alt=""></span>
</div>
<script src="https://www.nguoicodonvn2008.info/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-4,nv_my_abbr="EDT",nv_cookie_prefix="nv4c_e856T",nv_check_pass_mstime=1738000,nv_area_admin=0,nv_safemode=0,theme_responsive=0,nv_recaptcha_ver=2,nv_recaptcha_sitekey="",nv_recaptcha_type="image",XSSsanitize=1;</script>
<script src="https://www.nguoicodonvn2008.info/assets/js/language/vi.js"></script>
<script src="https://www.nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js"></script>
<script src="https://www.nguoicodonvn2008.info/assets/js/global.js"></script>
<script src="https://www.nguoicodonvn2008.info/assets/js/site.js"></script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/news.js"></script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/main.js"></script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/custom.js"></script>
<script type="application/ld+json">
        {
            "@context": "https://schema.org",
            "@type": "Organization",
            "url": "https://www.nguoicodonvn2008.info",
            "logo": "https://www.nguoicodonvn2008.info/uploads/angel.gif"
        }
        </script>
<script src="https://www.nguoicodonvn2008.info/themes/default/js/bootstrap.min.js"></script>
<script type="text/javascript">
var $scrolltop = $('.car-top');
$scrolltop.on('click', function () {
    $('html,body').animate({
        scrollTop: 0
    }, 800);
    $(this).addClass("car-run");
    setTimeout(function(){ $scrolltop.removeClass('car-run');}, 1000);
    return false;
});
$(window).on('scroll', function ()
{ 
    if($(window).scrollTop() >= 200)
    {
        $scrolltop.addClass("show");
        $scrolltop.addClass("car-down");
    }
    else
    {
       $scrolltop.removeClass("show");
       setTimeout(function(){ $scrolltop.removeClass('car-down');}, 300);
    }
});
</script>
</body>
</html>