Executing a jQuery function within a datalist control

I am facing an issue where I want to open a div when clicking on the anchor tag inside the data-list control. I tried searching for a solution on Google, but it doesn't seem to work as expected (the div does not open when I click on the anchor tag). I am curious to know why.

$( function () {
  $('a.detials').on('click', function (ev) {
    $(this).next('div').toggle();
  });
});
<asp:DataList ID="dtlRoomsPrice" Visible="false" orizontalAlign="center" runat="server" ShowFooter="False" ShowHeader="False" Width="700px" OnItemDataBound="dtlRoomsDetails_ItemDataBound">
    <ItemTemplate>


        <a href="javascript:void(0);" class="detials">ShowDetails</a>
        <div class="shoow" id="div_ID" style="width:687px;background-color: rgb(247, 239, 216);border-radius: 5px;box-shadow: 7px 6px 5px #888888; border: 2px solid gray; display:none;padding: 5px; ">
            <asp:Label ID="lblAmiintiesTxt" runat="Server" CssClass="shbe_label" Text="<%$ Resources:Resource,Amenities %>" Visible="false"></asp:Label>
            <p style="margin-top: 0px;margin-bottom: 0px;font-family: sans-serif; font-weight: bold; font-size: small;">Amenities</p>
            <asp:Label ID="lblAmiinties" runat="Server" CssClass="shbe_h2" Text='<%# Eval("Amenities") %>' Visible="true"></asp:Label>
            <br />

            <asp:Label ID="lblCanclText" Width="130" runat="server" CssClass="shbe_label" Visible="false" Text="<%$ Resources:Resource, Payment and Cancellation policy %>"></asp:Label>
            <p style="margin-bottom: 0px;font-family: sans-serif; font-weight: bold; font-size: small;">CancellationPolicy</p>
            <asp:Label ID="lblCancelation" runat="Server" CssClass="shbe_h2" Text='<%# Eval("CancellationPolicyText") %>' Visible="true"></asp:Label>

        </div>

    </ItemTemplate>
</asp:DataList>

Answer №1

give it a shot. see the magic happen.

$(function () {
    $(document).on("click",'a.show-info', function (ev) {
        $(this).next('div').toggle();
    });
});

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

Attempting to rename the "like" button in Django Ajax, however encountering difficulties

My button is currently functioning, but it's embedded within a Django for loop. I want to move the JavaScript logic to a separate file, but before that, I need to rename it appropriately. Check out this excerpt from my code: {% for post in posts %} ...

add .on("mouseover") and .on("mouseout") to a list

I am currently delving into the world of jquery and trying to grasp its concepts. One particular task I am working on involves displaying a random list element phrase upon loading the page. Here's the code snippet along with a link to a live demo on J ...

Determine whether an element possesses the rel="nofollow" attribute by utilizing CSS in Selenium test cases

In my Selenium test scripts, I am utilizing CSS selectors as element locators. Currently, my goal is to verify whether an element contains the attribute rel="nofollow" using CSS. Does anyone have insight on how to accomplish this task? ...

Ways to display title attributes when focused using jQuery?

Typically, title attributes in all browsers only appear when the mouse hovers over them. I am looking to also display them when users are focused on them via keyboard navigation. Unfortunately, without using JavaScript, this cannot be achieved solely throu ...

"Implementation of express-session limited to a single route file cannot be accessed in the app.js file of a

I am encountering an issue with the express-session in node js and express 4. I am setting a session variable inside the routes/index.js file, but it is not available in app.js. However, it is available in another route file users.js routes/index.js var ...

Manipulating viewport settings to simulate smaller screens on a desktop device

I am working with a parent container that contains Bootstrap div.row elements holding div.col-... child elements. I am using jQuery to adjust the width and height of the container dynamically to replicate mobile device sizes for users to preview different ...

The browser is capable of detecting multiple key presses using JavaScript

I'm attempting to trigger an action when certain keys are pressed simultaneously. The keys I need to detect are bltzr, but my browser only registers bltz without the final r. I've tried this on both Windows and OSX, but still can't capture ...

ASP.NET Core Ajax response is empty

function addNewTeam() { var teamName = $("teamField").val(); $.ajax({ type: "POST", url: 'AddNewTeam', contentType: "application/json;", data: { team: "HELLO H ...

Vue JS version 1.0.26 flips symbols on the front-end

After purchasing the Socialite Social Network Laravel Script developed by BootstrapGuru, I encountered an issue with the chat feature on my website. Upon entering text and symbols into the chat window, such as "how are you?", the displayed text appeared as ...

.htaccess keeps track of login information

Similar Query: HTTP authentication logout via PHP I have set up my website to protect a specific folder using .htaccess and .htpasswd. Initially, the login prompt works as expected and requires me to enter my credentials to access the protected conten ...

What is the best way to showcase JSON keys in Vue.js?

I have a JSON structure that resembles the following: { "data": [ { "name": "someName", "link": "http://somelink.com", ], "relevantArray": [ { "keyIWant": ...

Replace the element's style using a JavaScript object

While there are numerous versions of this query, the existing answers fail to provide in-depth analysis. Query: How does this result in a height of 200 pixels? Consider the following code snippet: var el = document.querySelector('#r'); cons ...

Store the Ajax JQuery selector within an array for safekeeping

I am completely new to working with Ajax and would appreciate some assistance in storing data from an Ajax request into an array. I have browsed through various solutions on this forum, but so far, I have been unable to resolve my issue. The Ajax respons ...

Display the dropdown submenu within the DIV upon hovering

Looking to create a hover/drop menu using DIVs without UL/LI elements. The current menu displays 3 options, but I want to add a submenu under Link 2. .dropbtn { background-color: #4CAF50; color: white; pad ...

Changing font color of a selected item in Material-UI's textview

I have a select textview in my react app and I am wondering how to change the font color after selecting an item from this textview. <div> <TextField id="standard-select-currency" select fullWidth l ...

A guide on utilizing Higher Order Components (HOC) to assign a specific value to a component within a React

Currently, I am working on creating a Higher Order Component (HOC) in React.js that assigns values to the "color" parameter in an icon component. I have three different colors available, each with its corresponding value: Primary: #f7a014 Secondary: ...

Unveiling the Quirk of Foundation 5: Grid Encounters a Popping

Recently, I encountered an issue with Foundation 5. Whenever I attempt to apply the "position:fixed" property on a "div" element that is part of the Foundation Grid, it causes the div to break out of the grid and align itself with the left edge of the ro ...

Can changes on a webpage in PHP be saved without needing to be sent to a database?

I've been conducting some research on this matter, but I haven't been able to find a solution. Is it feasible in PHP to save modifications made on a webpage without storing the information in a database? I want to empower users to edit their pag ...

The comparison between exposing and creating objects in a Nodejs router file

Recently, I began using expressjs 4.0.0 and was impressed by the express.Router() object. However, a dilemma arose when I moved all my routes to another file - how do I expose an object to the routes file? In my server.js file: ... var passport = ...

What is the best way to send the index variable to an HTML element in Angular?

Is there a way to pass the index variable to construct HTML in the append() function? .directive('grid', ['$compile', function(compile) { return { restrict: "E", scope: { elements: '=' ...