1

I'm trying to display an alert in the screen upon clicking an ID that starts with titleNotes and another ID that starts with "contentNotes". my first attempt in using such selector is with the use of .css("cursor", "pointer") which is a success, so i tried implementing such selector in the click event, which doesn't work. is there something wrong within my syntax?

Here's my script:

$(document).ready(function() {
    $("#changeIcon").click(function() {
        $(this).find("i").toggleClass("fa-th fa-list");
        $("body").find("#gridContainerMain").toggleClass("grid-container-3 grid-container-1");
        $("body").find("#fillerColumnTop").toggleClass("grid-item-whole-column-filler-3-grid-container-state grid-item-whole-column-filler-1-grid-container-state");
    });
    $("[id^='titleNotes'],[id^='contentNotes']").css("cursor", "pointer");
    $("[id^='titleNotes'],[id^='contentNotes']").click(function() {
        alert("try"); //this is not alerting the user
    }); 
    $("[id^='deleteNotes']").click(function() {
        var id = $(this).closest('div').attr('id');
        console.log(id);
        $.ajax({
            url: "ajax/deleteidentifier.php",
            type: "post",
            data: {
                id: id
            }
        })
        .done(function(response){
            if (JSON.parse(response)) {
                alert("Moved to deleted folder.");
                window.location.reload();
            }
            else {
                alert("Failed!");
            }
        });
    });
});
```
and here's the php code that contains the IDs in which the script would try to find

```
<?php
    include "db.php";
    $sql_display_notes = "SELECT * FROM notes WHERE user_id = '$account_id' AND archived_status = 'n' AND deleted_status = 'n'";
    $query_sql_display_notes = $conn->query($sql_display_notes);
    while ($result_query_sql_display_notes = $query_sql_display_notes->fetch_array()) {
        $note_record = $result_query_sql_display_notes["note_record"];
        $note_type = $result_query_sql_display_notes["note_type"];
        $note_title = $result_query_sql_display_notes["note_title"];
        $date_created = $result_query_sql_display_notes["date_created"];
        $note_id = $result_query_sql_display_notes["note_id"]
        ?>
            <div class="grid-padding-all" id="<?php echo $note_id; ?>">
                <button type="button" id="deleteNotes<?php echo $note_id; ?>" class="close" data-dismiss="modal">&times;</button>
                <input name="note_title" id="titleNotes<?php echo $note_id; ?>" class="note_display" disabled="" value="<?php echo $note_title ?>" title="created on <?php echo $date_created; ?>. Note type: <?php echo $note_type; ?>">
                </input>
                <textarea name="note_record" id="contentNotes<?php echo $note_id; ?>" class="note_display" disabled=""title="created on <?php echo $date_created; ?>. Note type: <?php echo $note_type; ?>"><?php echo $note_record; ?></textarea>
            </div>
        <?php
    }
?>
double-beep
  • 5,031
  • 17
  • 33
  • 41
Lex
  • 321
  • 4
  • 13
  • 2
    There is no element with `id="changeIcon"` in your code – Qirel Apr 23 '19 at 12:29
  • 2
    The element with id `changeIcon` seems to be missing. – Pupil Apr 23 '19 at 12:29
  • 2
    Use class instead of id for duplicate nodes – Cerlin Apr 23 '19 at 12:30
  • 2
    Welcome to Stack Overflow, always, talking about client-side code debugging should be regarded with the output of the browser's console. In other words, does your browser invoke any error messages? – SaidbakR Apr 23 '19 at 12:39
  • 1
    Using disabled inputs... `There is no way to capture a click on disabled elements`... check [here](https://stackoverflow.com/questions/16109228/clicking-a-disabled-input-or-button/16109366#answer-16109366). – skobaljic Apr 23 '19 at 12:41
  • 3
    Possible duplicate of [Clicking a disabled input or button](https://stackoverflow.com/questions/16109228/clicking-a-disabled-input-or-button) – skobaljic Apr 23 '19 at 12:42
  • 1
    @Pupil the changeIcon is used on another webpage. this is irrelevant on this one – Lex Apr 23 '19 at 12:52

0 Answers0