<!DOCTYPE html>
    <html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
    <head>
<title>Viết chương trình đảo ngược chuỗi bằng Python</title>
<meta name="description" content="Viết chương trình đảo ngược chuỗi bằng Python - 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="Viết chương trình đảo ngược chuỗi bằng Python">
<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;viet-chuong-trinh-dao-nguoc-chuoi-bang-python-7498.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/viet-chuong-trinh-dao-nguoc-chuoi-bang-python-7498.html">
<link rel="shortcut icon" href="https://nguoicodonvn2008.info/favicon.ico">
<link rel="canonical" href="https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/viet-chuong-trinh-dao-nguoc-chuoi-bang-python-7498.html">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/" title="Tin Tức" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/karaoke-dual/" title="Tin Tức - Karaoke Dual" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/nhac-tre/" title="Tin Tức - Nhạc trẻ" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/tru-tinh/" title="Tin Tức - Trữ tình" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/nuoc-ngoai/" title="Tin Tức - Nước ngoài" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/remix/" title="Tin Tức - Remix" type="application/rss+xml">
<link rel="alternate" href="https://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://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://nguoicodonvn2008.info/vi/news/rss/cuoc-song/" title="Tin Tức - Cuộc sống" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/phan-mem/" title="Tin Tức - Phần mềm" type="application/rss+xml">
<link rel="alternate" href="https://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://nguoicodonvn2008.info/vi/news/rss/hoc-tap/" title="Tin Tức - Học tập" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/tai-lieu/" title="Tin Tức - Tài liệu" type="application/rss+xml">
<link rel="alternate" href="https://nguoicodonvn2008.info/vi/news/rss/de-thi/" title="Tin Tức - Đề thi" type="application/rss+xml">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/style.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/news.css" type="text/css">
<link rel="preload" as="style" href="https://nguoicodonvn2008.info/themes/default/css/custom.css" type="text/css">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://nguoicodonvn2008.info/themes/default/js/bootstrap.min.js" type="text/javascript">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/themes/default/css/bootstrap.non-responsive.css">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/themes/default/css/style.css">
<link rel="stylesheet" href="https://nguoicodonvn2008.info/themes/default/css/style.non-responsive.css">
<link rel="StyleSheet" href="https://nguoicodonvn2008.info/themes/default/css/news.css">
<link rel="stylesheet" href="https://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://nguoicodonvn2008.info/">https://nguoicodonvn2008.info</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Viết chương trình đảo ngược chuỗi bằng Python</h1>
		<ul class="list-inline">
			<li>Thứ tư - 06/09/2023 11:02</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="Viết chương trình đảo ngược chuỗi bằng Python" src="https://st.quantrimang.com/photos/image/2017/10/19/vong-lap-for-python-200-size-80x80-znd.jpg" width="460" class="img-thumbnail" />
		</div>
		<div class="clear"></div>
		<div id="bodytext" class="clearfix">
			<p style="text-align: justify;"><strong>Đảo ngược chuỗi trong Python&nbsp;</strong>là gì?&nbsp;<strong>Cách dùng hàm đảo ngược chuỗi trong Python</strong>&nbsp;như thế nào? Hãy cùng Quantrimang.com tìm hiểu nhé!</p>

<p style="text-align: justify;">Lập trình hiện đang là một trong số ngành nghề “hot” nhất hiện nay. Sở dĩ như vậy bởi công nghệ là một xu thế tất yếu của thời đại. Công nghệ càng phát triển, cuộc sống con người càng tiện nghi và dễ dàng hơn. Lập trình chính là cốt lõi của công nghệ. Những dòng code tưởng chừng như vô nghĩa, khó hiểu, thực tế, nó có thể tạo ra cả một chương trình, phần mềm hữu ích cho đời sống.</p>

<p style="text-align: justify;">Hiện tại, bạn có nhiều lựa chọn ngôn ngữ lập trình khác nhau. Python là một lựa chọn nổi bật và phổ biến trong số đó. Không khó học lập trình bằng Python. Bạn có thể tham gia một khóa học bài bản hoặc tự học ngay tại nhà. Nếu chưa biết bắt đầu từ đâu, mời bạn tham khảo mục học Python cơ bản trên Quantrimang.com.</p>

<p style="text-align: justify;">Ở bài viết này, chúng ta hãy cùng nhau tìm hiểu về xâu đảo ngược Python, viết hàm đảo ngược chuỗi trong Python và những thông tin liên quan khác.</p>

<p style="text-align: justify;">Nếu đã theo nghề lập trình được một thời gian, ắt hẳn bạn đã từng phải đối mặt với tình huống cần đảo ngược một chuỗi. Thực tế, đây là vấn đề thường gặp khi phát triển web/app hoặc học code. Bạn có thể đảo ngược một chuỗi bằng cách dùng các hàm có sẵn hoặc viết code riêng để triển khai hàm đảo ngược.</p>

<p style="text-align: justify;">Python có nhiều hàm chuỗi hữu ích, chẳng hạn như casefold() chuyển đổi một chuỗi sang chữ viết thường. Không có hàm đảo ngược chuỗi trong ngôn ngữ này. Tuy nhiên, bạn có nhiều phương pháp đơn giản để đảo ngược chuỗi trong Python.</p>

<p style="text-align: justify;">Phương pháp bạn chọn phụ thuộc vào sở thích cá nhân. Bài viết dưới đây sẽ tổng hợp cho bạn các cách đảo ngược chuỗi trong Python đơn giản nhất.</p>

<h2 style="text-align: justify;">&nbsp;</h2>

<p style="text-align: justify;"><strong>Đề bài:&nbsp;</strong>Cho muỗi chuỗi ký tự, hãy viết chương trình để in ra chuỗi kỹ tự đó theo thứ tự được đảo ngược.</p>

<p style="text-align: justify;">Ví dụ:</p>

<pre id="pre0">
<code>Input:  Quantrimang
Output: gnamirtnauQ</code></pre>

<h2 id="mcetoc_1h9kq6vah58" style="text-align: justify;">1. Đảo ngược một chuỗi trong Python bằng vòng lặp</h2>

<p style="text-align: justify;">Trong ví dụ này, chúng ta gọi một hàm để đảo ngược một chuỗi, hàm này lặp lại mọi phần tử và nối từng ký tự ở đầu một cách thông minh để thu được chuỗi đã đảo ngược.</p>

<p style="text-align: justify;">Code mẫu:</p>

<pre id="pre1" style="text-align: justify;">
def reverse(s):
    str = &quot;&quot;
    for i in s:
        str = i + str
    return str
s = &quot;Quantrimang&quot;
print(&quot;Chuỗi ban đầu là : &quot;, end=&quot;&quot;)
print(s)
print(&quot;Chuỗi đã được đảo ngược (sử dụng vòng lặp) là : &quot;, end=&quot;&quot;)
print(reverse(s))</pre>

<h2 id="mcetoc_1h9kq6vah59" style="text-align: justify;">2. Đảo ngược một chuỗi trong Python bằng đệ quy</h2>

<p style="text-align: justify;">Chuỗi được truyền dưới dạng đối số cho một hàm đệ quy để đảo ngược chuỗi. Trong hàm, điều kiện cơ bản là nếu độ dài của chuỗi bằng 0 thì chuỗi được trả về. Nếu không bằng 0, hàm đảo ngược được gọi đệ quy để cắt một phần của chuỗi ngoại trừ ký tự đầu tiên và nối ký tự đầu tiên với phần còn lại chủa chuỗi.</p>

<p style="text-align: justify;">Code mẫu:</p>

<pre id="pre2" style="text-align: justify;">
def reverse(s):
    if len(s) == 0:
        return s
    else:
        return reverse(s&#91;1:&#93;) + s&#91;0&#93;
s = &quot;Quantrimang&quot;
print(&quot;Chuỗi ban đầu là : &quot;, end=&quot;&quot;)
print(s)
print(&quot;Chuỗi đã được đảo ngược (sử dụng đệ quy) là: &quot;, end=&quot;&quot;)
print(reverse(s))</pre>

<h2 id="mcetoc_1h9kq6vah5a" style="text-align: justify;">3. Đảo ngược một chuỗi trong Python bằng ngăn xếp</h2>

<p style="text-align: justify;">Một ngăn xếp trống được tạo ra. Từng ký tự một của chuỗi được đẩy vào ngăn xếp. Lần lượt tất cả các ký tự trong ngăn xếp được đưa ra và đưa trở lại chuỗi.</p>

<p style="text-align: justify;">Code mẫu:</p>

<pre id="pre3" style="text-align: justify;">
# Function to create an empty stack. It
# initializes size of stack as 0
def createStack():
    stack = &#91;&#93;
    return stack
# Function to determine the size of the stack
def size(stack):
    return len(stack)
# Stack is empty if the size is 0
def isEmpty(stack):
    if size(stack) == 0:
        return true
# Function to add an item to stack . It
# increases size by 1
def push(stack, item):
    stack.append(item)
# Function to remove an item from stack.
# It decreases size by 1
def pop(stack):
    if isEmpty(stack):
        return
    return stack.pop()
# A stack based function to reverse a string
def reverse(string):
    n = len(string)
    # Create a empty stack
    stack = createStack()
    # Push all characters of string to stack
    for i in range(0, n, 1):
        push(stack, string&#91;i&#93;)
    # Making the string empty since all
    # characters are saved in stack
    string = &quot;&quot;
    # Pop all characters of string and put
    # them back to string
    for i in range(0, n, 1):
        string += pop(stack)
    return string
# Driver code
s = &quot;Quantrimang&quot;
print(&quot;Chuỗi ban đầu là : &quot;, end=&quot;&quot;)
print(s)
print(&quot;Chuỗi sau khi đảo ngược (sử dụng ngăn xếp) là: &quot;, end=&quot;&quot;)
print(reverse(s))</pre>

<h2 id="mcetoc_1h9kq6vah5b" style="text-align: justify;">4. Đảo ngược một chuỗi trong Python bằng slice extended</h2>

<p style="text-align: justify;">Slice extended đề nghị đặt trường &quot;step&quot; là &#91;start, stop, step&#93; và không đặt trường nào là start và stop cho biết giá trị mặc định tương ứng là 0 và độ dài chuỗi, và &quot;-1&quot; biểu thị bắt đầu từ cuối và stop ở start, do đó đảo ngược một chuỗi.</p>

<p style="text-align: justify;">Code mẫu:</p>

<pre id="pre4" style="text-align: justify;">
# Function to reverse a string
def reverse(string):
    string = string&#91;::-1&#93;
    return string
s = &quot;Quantrimang&quot;
print(&quot;Chuỗi ban đầu là : &quot;, end=&quot;&quot;)
print(s)
print(&quot;Chuỗi sau khi được đảo ngược (sử dụng slice extended) là: &quot;, end=&quot;&quot;)
print(reverse(s))</pre>

<h2 id="mcetoc_1h9kq6vah5c" style="text-align: justify;">5. Đảo ngược một chuỗi trong Python bằng phương thức reversed()</h2>

<p style="text-align: justify;">Phương thức reversed() trả về trình lặp đảo ngược của chuỗi đã cho và sau đó các phần tử của chuỗi được nối với chuỗi rỗng đã được phân tách bằng cách sử dụng join(). Và chuỗi thứ tự đảo ngược được hình thành.</p>

<p style="text-align: justify;">Code mẫu:</p>

<pre id="pre5" style="text-align: justify;">
# Python code to reverse a string
# using reversed()
# Function to reverse a string
def reverse(string):
    string = &quot;&quot;.join(reversed(string))
    return string
s = &quot;Quantrimang&quot;
print(&quot;Chuỗi ban đầu là: &quot;, end=&quot;&quot;)
print(s)
print(&quot;Chuỗi sau khi đảo ngược (sử dụng reversed) là: &quot;, end=&quot;&quot;)
print(reverse(s))</pre>

<p style="text-align: justify;">Phương pháp slice nhanh hơn chủ yếu do hàm join() tạo một danh sách mới. Tuy nhiên, dùng hàm join() lại dễ đọc hơn. Nó là phương pháp đáng thử nhất nếu chương trình không có chú thích.</p>

<h2 id="mcetoc_1h9kq6vah5d" style="text-align: justify;">6. Đảo ngược một chuỗi trong Python bằng list comprehension()</h2>

<p style="text-align: justify;">List comprehension tạo danh sách các phần tử của một chuỗi theo thứ tự ngược lại và sau đó các phần tử của nó được nối bằng cách sử dụng join(). Và chuỗi theo thứ tự đảo ngược được hình thành.</p>

<p style="text-align: justify;">Code mẫu:</p>

<pre id="pre6" style="text-align: justify;">
# Function to reverse a string
def reverse(string):
    string = &#91;string&#91;i&#93; for i in range(len(string)-1, -1, -1)&#93;
    return &quot;&quot;.join(string)
s = &quot;Quantrimang&quot;
print(&quot;Chuỗi ban đầu là: &quot;, s)
print(&quot;Chuỗi sau khi đảo ngược (sử dụng list comprehension) là : &quot;, reverse(s))</pre>

<h2 id="mcetoc_1h9kq6vah5e" style="text-align: justify;">7. Đảo ngược một chuỗi trong Python bằng lệnh gọi hàm</h2>

<p style="text-align: justify;">Hàm sẽ đảo ngược một chuỗi bằng cách chuyển đổi nó thành danh sách sau đó đảo ngược nó và chuyển đổi lại thành chuỗi.</p>

<p style="text-align: justify;">Code mẫu:</p>

<pre id="pre7" style="text-align: justify;">
# Function to reverse a string
# by converting string to list
# then reversed it and again convert it to string
def reverse(string):
    string = list(string)
    string.reverse()
    return &quot;&quot;.join(string)
s = &quot;Quantrimang&quot;
print(&quot;Chuỗi ban đầu là: &quot;, s)
print(&quot;Chuỗi đã được đảo ngược (sử dụng lệnh gọi hàm) là: &quot;, reverse(s))
# This code is contributed by Susobhan AKhuli</pre>

<h2 id="mcetoc_1h9kq6vah5f" style="text-align: justify;">So sánh hiệu suất của các xâu đảo ngược Python</h2>

<p style="text-align: justify;">Dưới đây là cách so sánh hiệu quả giữa các phương thức đảo ngược xâu trong Python.</p>

<ol>
	<li style="text-align: justify;">Để lặp lại các bài kiểm tra hiệu suất trên hệ thống:</li>
	<li style="text-align: justify;">Tạo file Python tên&nbsp;<strong>reverse_strings.py</strong>.</li>
	<li style="text-align: justify;">Sao chép &amp; dán tất cả phương thức đảo ngược chuỗi vào file.</li>
	<li style="text-align: justify;">Mở cửa sổ dòng lệnh hoặc&nbsp;<strong>terminal</strong>.</li>
	<li style="text-align: justify;">Chạy các lệnh&nbsp;<strong>terminal&nbsp;</strong>bên dưới để thấy thời gian thực thi.</li>
</ol>

<pre id="pre8" style="text-align: justify;">
$ python3 -m timeit --number 100000 --unit usec &#039;import reverse_strings&#039; &#039;reverse_strings.reverse_slicing(&quot;This is just a tests&quot;)&#039;
100000 loops, best of 5: 0.377 usec per loop
$ python3 -m timeit --number 100000 --unit usec &#039;import reverse_strings&#039; &#039;reverse_strings.reverse_for_loop(&quot;This is just a tests&quot;)&#039;
100000 loops, best of 5: 1.84 usec per loop
$ python3 -m timeit --number 100000 --unit usec &#039;import reverse_strings&#039; &#039;reverse_strings.reverse_while_loop(&quot;This is just a tests&quot;)&#039;
100000 loops, best of 5: 2.94 usec per loop
$ python3 -m timeit --number 100000 --unit usec &#039;import reverse_strings&#039; &#039;reverse_strings.reverse_with_join(&quot;This is just a tests&quot;)&#039;
100000 loops, best of 5: 1.01 usec per loop
$ python3 -m timeit --number 100000 --unit usec &#039;import reverse_strings&#039; &#039;reverse_strings.reverse_with_list(&quot;This is just a tests&quot;)&#039;
100000 loops, best of 5: 0.87 usec per loop
$ python3 -m timeit --number 100000 --unit usec &#039;import reverse_strings&#039; &#039;reverse_strings.reverse_recursively(&quot;This is just a tests&quot;)&#039;
100000 loops, best of 5: 6.29 usec per loop</pre>

<p style="text-align: justify;">Như bạn thấy, phương pháp tiếp cận bằng slice là nhanh nhất.</p>

<p style="text-align: justify;">Mong rằng bài viết này sẽ có ích với các bạn!</p>
		</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/viet-chuong-trinh-dao-nguoc-chuoi-bang-python-7498.html" title="Viết chương trình đảo ngược chuỗi bằng Python">https://www.nguoicodonvn2008.info/vi/news/savefile/kien-thuc-may-tinh/viet-chuong-trinh-dao-nguoc-chuoi-bang-python-7498.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://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://nguoicodonvn2008.info/themes/default/images/car.png" alt=""></span>
</div>
<script src="https://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://nguoicodonvn2008.info/assets/js/language/vi.js"></script>
<script src="https://nguoicodonvn2008.info/assets/js/DOMPurify/purify3.js"></script>
<script src="https://nguoicodonvn2008.info/assets/js/global.js"></script>
<script src="https://nguoicodonvn2008.info/assets/js/site.js"></script>
<script src="https://nguoicodonvn2008.info/themes/default/js/news.js"></script>
<script src="https://nguoicodonvn2008.info/themes/default/js/main.js"></script>
<script src="https://nguoicodonvn2008.info/themes/default/js/custom.js"></script>
<script type="application/ld+json">
        {
            "@context": "https://schema.org",
            "@type": "Organization",
            "url": "https://nguoicodonvn2008.info",
            "logo": "https://nguoicodonvn2008.info/uploads/angel.gif"
        }
        </script>
<script src="https://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>