简体   繁体   中英

Not able to print the variable in chrome dev tools javascript console

Below image is pointing the value of username (updatedBy) ie 52038862. I want to print this value by calling the variable which stores this value. The value displayed in the table.

在此输入图像描述

How to fetch the variable name and print this in javascript console. I need to display this value in some other pages. I am newly debugging the application. I am stuck at this point. Below is my jsp code.

<label>Approval History</label>        
            </div>
            <div class="tile-body">
                <div class="tableWrapAtX">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>Date/Time</th>
                                <th>User</th>
                                <th>Email Address</th>
                                <th>Old Status</th>
                                <th>New Status</th>
                                <th>Comment</th>                                
                            </tr>
                        </thead>
                        <tbody>                                         
                            <!-- ko foreach: approvalAuditTrail -->
                                <tr>
                                    <td><span data-bind="text: updated"></span></td>
                                    <td><span data-bind="text: updatedBy"></span></td>
                                    <td><span data-bind="text: updatedByEmail"></span></td>
                                    <td><span data-bind="text: oldStatus"></span></td>
                                    <td><span data-bind="text: approvalStatus"></span></td>
                                    <td><span data-bind="text: comments"></span></td>
                                </tr>
                            <!-- /ko -->
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

Could you assign an ID to the field and reference it that way?

<td><span id="updateby" data-bind="text: updatedBy"></span></td>

Create a variable $foo to reference this data in the DOM.

$foo = document.querySelector('span#updateby');

Retrieve properties of the $foo variable, specifically the actual int values

$foo.textContent;

There are different ways to reference as well and this simple example is based on my understanding of the question.

谷歌Chrome控制台输出

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM