Exploration of search box with highlighted fields

Seeking assistance to enhance the highlighting feature after entering a letter in the search box. Here is the current code snippet:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="javascripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="javascripts/jquery-ui-1.11.0.custom/external/jquery/jquery.js"></script>
<script type="text/javascript" enter code heresrc="javascripts/jquery-ui-1.11.0.custom/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="javascripts/jquery-ui-1.11.0.custom/jquery- ui.css">
<script type="text/javascript" src="jquerysearch.js"></script>
<script type="text/javascript">
            //Communication to PHP file and server
            function searchq() {
                var searchTxt = $("#searchbox").val();
                $(function() {
                    $("#searchbox").autocomplete({
                        appendTo: function(request, response) {
                            $.post("tagasearch4.php", {
                                searchVal: searchTxt
                            }, function(output) {
                                $("#output").html(output);
                                var myFunction = function(i) {
                                    $(this).attr('tabindex', i - 0)
                                };
                                $("li").each(myFunction)
                                $('li').addClass('selected');
                                $('input').addClass('menu');
                            });
                        }
                    });
                });
                $("#searchbox").keypress(function() {
                    $("#output").css("border-style", "inset");
                });
            };
            //Adding custom effects to List 
            $("table").mouseover(function() {
                $("table").css("paddingLeft", "60px");
            });
            $("li").mouseout(function() {
                $("li").css("background-color", "white");
            });
            //Adding custom effects to SearchBox
            $(function() {
                $('#searchbox').click(function() {
                    $(this).effect('highlight')
                });
            });
        </script>
<style type="text/css">
            th {
                border-color: skyblue;
            }
            th {
                text-align: center;
            }
            th {
                border-radius: 7%;
            }
            table {
                padding-left: 60px;
            }
            nav ul li:hover {
                background: blue;
            }
            nav ul li {
                cursor: pointer;
            }
</style>
</head>
<body>
<form method="post" action="" class="searchbox" autocomplete="off">
    <label for="search">Member:</label>
    <input name="searchbox" type="text" onkeydown="searchq()" placeholder="SEARCH" id="searchbox" size="40" maxlength="70"/>
    <nav role="navigation">
    <ul style="list-style-type: none" id="list" type="text">
        <li id="output"></li>
    </ul>
    </nav>
</form>
</body>
</html>

The current behavior only highlights all fields in the autosuggestion box.

Answer №1

If possible, providing a JSFiddle would enhance clarity.

Assuming the "searchbox" refers to an input field and you wish to highlight the "output" when the user changes the input in the searchbox:

To achieve this, consider the following code snippet:
JS:

$("#searchbox").change(function() {
    $("#output").addClass("highlight");
});

A corresponding CSS style rule should be added:

.highlight{
    border: red;
    background-color: yellow;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The grid is evenly populated with icons

Is it possible to evenly distribute the icons by only using CSS? I'm aiming to achieve a result similar to this (unfortunately, I can't post images due to my lack of reputation). You can find an example solution that uses JavaScript here: _htt ...

Guide to utilizing the importcss plugin in TinyMCE Version 4.0.10: Troubleshooting content_css loading issue and resolving style dropdown display problem

We are currently using the latest version of TinyMCE, specifically v 4.0.10 Our goal is to load content_css and have a dropdown of styles available in the styleselect menu. According to TinyMCE 4.x documentation, we attempted to achieve this by incorpora ...

Center an element on the screen by dynamically adjusting its position according to the media query

As I work on creating a responsive website that can adapt to screens of various devices, I am facing a challenge. Each device has a different number of pixels, making it difficult to centrally position a div dynamically. Currently, I am using margin-left: ...

Adding an automatically generated link within an HTML form

I am working on a web page that displays dynamic content and includes a form for user submissions. How can I add a unique reference to each of these pages within the form? <div class="detalle-form-wrap"> <div> <h1> ...

Looking for a solution to split barcode data across two text fields

I am looking to enhance my data input process by utilizing a barcode scanner in conjunction with JQuery. The barcode scanner I have reads both the serial number and model name of each product, but currently displays them together in one text field. Is ther ...

Scrollspy in bootstrap incorrectly highlights the navigation item as active

I seem to be having an issue with bootstrap scrollspy. For example: <header class="header pb-4 pb-lg-0 pt-4 sticky-top bg-white"> ... </header> <div class="container-fluid width content-main" data-bs-spy=" ...

Creating a Line Chart Using an HTML Table

I am a beginner when it comes to understanding charts and MVC. Currently, I am attempting to develop a line chart to represent tabular data in MVC. Below is a snippet of the sample data that I am working with: <div class="panel-body table-responsive"&g ...

Determine the total number of elements within the Map tag using JSOUP

Hello, I am currently working on developing a web crawler using Java. One of the functionalities I need is to count the total number of sections present on the current page. These sections are located within area tags contained in a Map tag. Despite using ...

Sending an Ajax request to a nearby address

I'm feeling a bit lost on how to achieve this task. I've been searching online, but it seems like my search terms may not have been quite right. My goal is to set up a RESTful api. $.ajax({ type: "POST", url: "https//my.url/", data: ...

Is it possible to utilize CSS alone to change the color of a certain image to white against a black background?

I specialize in crafting dark theme versions of popular websites using CSS. One challenge I often face is dealing with images like the ones below: https://i.sstatic.net/ZLpPT.png https://i.sstatic.net/2NKRP.png Websites typically use background-image t ...

Firefox's handling of collapsing margins

Summary: Visit this codepen for an example that works smoothly on Chrome, but shows misalignment in Firefox. I have been working on a custom jQuery plugin that enhances a text input by adding a dropdown button on the left side. To ensure proper positionin ...

What is the best way to sort and organize JSON data?

Upon successful ajax call, I receive JSON data structured like this: var videolist = [ { "video_id": 0, "video_name": "Guerrero Beard", "timelength": 15 }, { "video_id": 1, "video_name": "Hallie Key", "timelength": 8 }, { ...

Unexpected labels continue to pop up in the footer of the HTML file

I have noticed that the following HTML always appears at the very bottom of the body tag in all my projects, regardless of whether I am using React.js or not. Interestingly, when I switch to an incognito browser, these tags disappear. Curiously, these sa ...

Each time the toggle is switched, an additional AJAX request is sent to the PHP document

I've been working on a function that sends data to a PHP file, which then processes the data. The PHP part works fine, but I'm having issues with the jQuery side of things. Each time I click on a ".work" element and trigger the toggle function, a ...

jQuery Mobile and Phonegap: Content Disappears from Page Header After Transition Finish

My phonegap (2.2.0) + jquery mobile (1.2.0) app is experiencing a peculiar problem. There is a page in my app with a link that loads another page. On the loaded page, there is a back button that takes the user back to the previous page when clicked. This ...

Display information retrieved from database query in HTML

As someone who is new to PHP, I am determined to learn and improve my programming skills through it. Currently, I have incorporated the following PHP code into my webpage to fetch data from my database: <?php //code missing to retrieve my ...

Parsing JSON data from a PHP response using jQuery

Here is the code snippet I am working with using jQuery: var dataString = "class_id="+class_id; $.ajax({ type: "POST", url: "page.php", data: dataString, success: function (msg) { //stuck here }, error: function () { ...

How to Retrieve URL Before Closing a jQuery Window Using window.open()?

Is it feasible to retrieve the URL of a window.open window after triggering a window.close event when the user clicks the close button? How can I obtain the last URL visited right before the window closes? ...

Create a sleek design by aligning labels with CSS 3 fancy radio buttons

I have a radio button with a larger circle that needs to be 38px input[type=radio] { visibility: hidden; } .label { font-weight: normal; color: #333; } .label::before { content: ''; position: absolute; left: 0; w ...

Pressing a shortcut key will direct the focus to the select tag with the help of Angular

I was trying to set up a key shortcut (shift + c) that would focus on the select tag in my form when pressed, similar to how tab works. Here is the HTML code for my form's select tag: <select id="myOptions"> <option selected> Opti ...