What is causing the malfunction of these three links?

Discover the yellow section below the images labeled "Read more about /college/" on .

The first 3 links (Columbia, Princeton, and Brown) are not functioning properly, while the others are. An error in JavaScript is being raised stating

Uncaught Error: Syntax error, unrecognized expression: /columbia/academics/professors/1
. What could be causing this issue?

UPDATE After updating the JavaScript to:

$('#left > li > a').click(function (e) {
    e.preventDefault();
    $(this).tab('show');
});

The problem has been resolved.

HTML

<%= link_to "Get Paid to Answer Questions", "/the-deal", id: "the_deal", class: "btn btn-link" %>
<h1 id="heading">In-Depth Reviews of Colleges</h1>
<div class="tabbable">
    ... (omitted for brevity)
</div>

<div id="notify">
    <p>Presently, reviews are available only for these 12 schools. Provide your email address below to receive notifications when new reviews are added!</p>
    <span id="notify_span">
        <%= simple_form_for :subscribe, url: 'subscribe' do |f| %>
            <%= f.input :email, placeholder: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fa8f899f88ba9e95979b9394d4999597">[email protected]</a>', label: false, required: true %> <br/>
            <%= f.button :submit, "1-Click Sign Up", class: "btn btn-primary", data: { :disable_with => "Submitting..." } %>
        <% end %>
    </span>     
</div>

<ul id="bottom_links">
    <li><%= link_to "I Graduated High School. Now What?", "/i-graduated-high-school-now-what" %></li>
    <li><%= link_to "How to Choose a College", "/how-to-choose-a-college" %></li>
    <li><%= link_to "How College Inside View Got Started", "https://medium.com/what-i-learned-building/322e8668ed6f" %></li>
</ul>

JS

$('#columbia > a, #princeton > a, #brown > a, #penn > a, #harvard > a, #yale > a, #cornell > a, #dartmouth > a, #pitt > a, #wisconsin > a, #colgate > a, #adelphi > a').click(function (e) {
    e.preventDefault();
    $(this).tab('show');
})

CSS

@import "bootstrap";
@import "animations";

#home_css {
    max-height: 1200px !important;
    #the_deal {
        float: right;
        font-size: 12px;
    }
    ... (styling details omitted for brevity)
}

Answer №1

The arrangement of your HTML code between the functioning and non-functioning divs differs.

        <div class="tab-pane fade active in" id="columbia">
            <%= image_tag "columbia1.jpg", size: "297x187", class: 'picture' %>
            <%= image_tag "columbia2.jpg", size: "297x187", class: 'picture' %>
            <%= image_tag "columbia3.jpg", size: "297x187", class: 'picture' %>
            <%= link_to "&bull; &bull; Read more about Columbia &bull; &bull;".html_safe, "/columbia/academics/professors/1", class: 'school_link' %>
            <div class="right">
                <p class="question" class="well"><strong>How does the workload impact your social life?</strong></p>
                <%= image_tag "columbia_social_atmosphere_7.png", class: 'answers' %>
                <%= link_to '--read more--', '/columbia/social-life/social-atmosphere/7', class: 'read_more' %>
            </div>
        </div>
        <div class="tab-pane fade" id="princeton">
            <%= image_tag "princeton1.jpg", size: "297x187", class: 'picture' %>
            <%= image_tag "princeton2.jpg", size: "297x187", class: 'picture' %>
            <%= image_tag "princeton3.jpg", size: "297x187", class: 'picture' %>
            <%= link_to "&bull; &bull; Read more about Princeton &bull; &bull;".html_safe, "/princeton/academics/professors/1", class: 'school_link' %>
            <div class="right">
                <p class="question" class="well"><strong>How would you make your classes better?</strong></p>
                <%= image_tag "princeton_classes_6.png", class: 'answers' %>
                <%= link_to '--read more--', '/princeton/academics/classes/6', class: 'read_more' %>
            </div>
        </div>
        <div class="tab-pane fade" id="brown">
            <%= image_tag "brown1.jpg", size: "297x187", class: 'picture' %>
            <%= image_tag "brown2.jpg", size: "297x187", class: 'picture' %>
            <%= image_tag "brown3.jpg", size: "297x187", class: 'picture' %>
            <%= link_to "&bull; &bull; Read more about Brown &bull; &bull;".html_safe, "/brown/academics/professors/1", class: 'school_link' %>
            <div class="right">
                <p class="question" class="well"><strong>Are people intellectual? Do they have thoughtful conversations with each other?</strong></p>
                <%= image_tag "brown_social_atmosphere_5.png", class: 'answers' %>
                <%= link_to '--read more--', '/brown/social-life/social-atmosphere/5', class: 'read_more' %>
            </div>
        </div>

The above sections are not functioning correctly. Below is an example that is functioning properly.

        <div class="tab-pane fade" id="penn">
            <div class="left_pane"> 
                <%= image_tag "university-of-pennsylvania1.jpg", size: "297x187", class: 'picture' %>
                <%= image_tag "university-of-pennsylvania2.jpg", size: "297x187", class: 'picture' %>
                <%= image_tag "university-of-pennsylvania3.jpg", size: "297x187", class: 'picture' %>
                <%= link_to "&bull; &bull; Read more about Penn &bull; &bull;".html_safe, "/university-of-pennsylvania/academics/professors/1", class: 'school_link' %>
            </div>
            <div class="right">
                <p class="question" class="well"><strong>Are your classes too hard, or too easy? Why?</strong></p>
                <%= image_tag "penn_dificulty_4.png", class: 'answers' %>
                <%= link_to '--read more--', '/university-of-pennsylvania/academics/difficulty/4', class: 'read_more' %>
            </div>
        </div>

A comparison reveals that functional colleges follow this structure:

<div id="columbia">
  <div class="left_pane">
    <a>relevant link</a>
  </div>
  <div class="right">
  </div>
</div>

Meanwhile, non-functional sections are structured like this:

<div id="columbia">
  <a>relevant link</a>
  <div class="right">
  </div>
</div>

This structural difference seems to be causing issues with some JavaScript selectors on your page. Although there's no explicit problem in the provided code, it's worth investigating to prevent future complications.

Even if you decide to switch to using classes instead of IDs (which is a good practice), understanding the root cause of the structure discrepancy is crucial to avoid potential glitches down the line.

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

Using Ajax.Updater to run JavaScript code

I've tried numerous online tutorials and examples, but haven't had much success... I'm looking to execute JavaScript from an HTML Response in Ajax. Here's my code snippet: <script src="prototype.js" type="text/javascript"></ ...

When a d3 event is triggered by clicking, the value should be saved in a textbox

After clicking the checkbox, I would like to have all the checked client IP values automatically populate a textbox within the div called "ip." Here is my code snippet: <html> <body> <div id="ipDiv"> Client_ip :<input ty ...

establishing the dimensions of table data cells

I'm facing a challenge with setting the width and height for table data that changes dynamically based on different values. The dimensions of the table itself are not definite, so I need to find a solution. Here's the code snippet I'm curren ...

Displaying all items in the flexbox in a single row by decreasing the width of each individual box

After some tweaking, I now have a lineup of boxes styled like this: Check out the code in action on Codepen. Unfortunately, StackOverflow doesn't display it accurately. This is the CSS I implemented: @font-face { font-family: "Heebo-Light"; src: ...

The data type 'string | number | boolean' cannot be assigned to type 'undefined'. Specifically, the type 'string' is incompatible with type 'undefined'. Error code: ts(2322)

When attempting to create a partial object with specific fields from a full object that meet certain criteria, I encountered a TypeScript error message. To better explain this issue, I designed a test module to showcase the concept/problem without using ac ...

What is the best way to display fewer pages in Pagination on a mobile view?

Issue We need to display fewer pages in the mobile view so that it can align with the heading (My Orders) on the same line. https://i.sstatic.net/JROvk.png Resource material-ui/pagination Current Progress I have successfully removed the Next and Prev ...

PHP isn't sending data (even though the name tag is defined)

After reviewing numerous posts where individuals forget to include the name attribute in their input tags, I came up with a simple script: <form action="submit_form.php" method="post"> Name: <input type="text" name="name"><br> ...

In my Laravel + Bootstrap 4 application, there are occasional delays in Vue loading

After upgrading Bootstrap on my Laravel 7 application from version 3.x to 4.5.0 and running Vue 2.6.11, I noticed some strange behavior. What happens is that I sometimes see unparsed Vue code in the browser. Then, a split second later, the page reloads an ...

Utilizing JavaScript to implement a single method across multiple objects

Recently, I encountered a problem while trying to use the prototype method to apply the same function or variable to multiple objects. Despite creating numerous objects in the following manner: var item = { a: { aa: "lalala", ab: 1, somethin ...

Retrieve information from the API every second

In my React Native app, I have a system where customer orders are fetched and displayed on the restaurant side in a specific screen. I'm using the Fetch API to retrieve this data. The workflow is as follows: the customer places an order, which is then ...

The user values in jQuery alert function are correct, but the saveorupdate function fails to save null values in the database table

While using the alert function in jQuery, the user input values are alerted correctly, but for some reason they are being stored as null in the database table. Can anyone help me identify what might be causing this issue or what I might be doing wrong? I& ...

Is it possible to add a bottom border without having slanted corners?

I am looking to design a box with different colors - red on the left, right, and top, and grey at the bottom. However, I want the bottom border of the box to be flat. HTML <div class="ts"></div> CSS .ts { height:100px; width:100 ...

Website: Showcase Opentok using a Picture-in-Picture design

Currently, I am utilizing Opentok.js and my objective is to showcase both the subscriber and publisher within a Picture-in-Picture layout. I require this setup to be responsive and retain its aspect ratio when resizing the window. Additionally, I need gu ...

What could be causing the paragraph margins to overlap and not display properly?

Two pages with identical layout and CSS stylesheets. One page displays correctly, while the other has overlapping margins for paragraphs. Unable to share entire source code due to length. Seeking insight into potential causes of this issue. https://i.sst ...

Incorporate a Bootstrap panel featuring a stylish border design and perfectly centered text

I am attempting to design two panels in Bootstrap with centered text and different fonts. Similar to the layout shown in the image below https://i.sstatic.net/aVGwV.png Here is my code: <div class="row"> <div class="col-lg-6&q ...

Sustain unbroken websocket connection with Discord using Node.js

I've been working on developing a Discord bot using the raw API, but I've encountered an issue where the bot stops functioning after some time. I suspect that this is due to neglecting to maintain the websocket connection. How can I ensure that ...

The Python Selenium Guide to Accepting Cookies on Web Pages without an ID or Name

I am struggling to find a way to click on a button labeled "Alles akzeptieren" in order to accept the cookies on this website. On other sites, I have successfully used an ID or name attribute to locate and interact with buttons, but on this particular site ...

Fluid-width sidebars that don't require scrolling in a 3-column layout design (jsFiddle)

I need to design a layout with three columns, where the left column has a fixed width and the middle and right columns each take up 50% of the remaining space. It is also important that the left and right columns do not scroll along with the page. I have ...

"Enhance Your Website with jQuery: Organized Lists with Fixed Length, Connected,

I currently have a list that is separated into three columns, structured as follows: Column1 Column2 Column3 1 4 7 2 5 8 3 6 9 The list ranges from 1 to 9 and each column consists of a fixed number of rows (3). I am lo ...

Issues with the functionality of the ZeroClipboard Angular plugin

"> I'm fairly new to Angular and currently experimenting with a module called ZeroClipboard. I've made adjustments to my application in order to incorporate the module and configured it as per the demonstration. var app = angular.module ...