document.querySelector with AppleScript / Safari
You haven't closed any quotes or brackets. You need the following four characters.

var theStatus = document.querySelector('class[details="(valueIneed)"]')
                                                                   ^^^^


This is now syntactically correct JavaScript. I still doubt it'll do what you need, but without seeing the DOM of the page you're running this on and a full problem description I can't say for sure.

Given the update to your question with a snippet of HTML, the code you're trying won't work. To get the inner HTML of the element, use the following JavaScript:

document.querySelector("td.orderDetails .details").innerHTML;